Is it possible to store view code in files? - couchbase

Right now I enter view code (map & reduce) in the couchbase UI. This is very inconvenient, and I was wondering if there is a way to make couchbase scan the code from a folder?
This will allow me to put this code under version control, and allow me to create a script that copies code between environments.

I dont know of a 'native' way to store views in files, but you can add and remove views via REST. So you could implement a workaround.
Views REST API

Related

Chrome Extension and IndexDB Integration

So, I am working on a project(building a chrome extension) that requires data to be stored on the local machine of the user. The size of data is quite large hence I thought of using IndexDB for this purpose.
My Question is whether is it possible to connect a chrome extension with IndexDB and query the database at the same time??
If Yes, Then how can I integrate them. In which file(popup.js or background.js or any other file) should I include the source code for creating the database.
I want the code for creating the database to run only once. After that I only want to update or delete data only.
If No, then is there any other way to achieve this?? The data is large hence I cannot store data in local storage.
Any paper, online material, advice or method from chrome developers or any other valid site would be helpful. Any example would help me alot.
Thankyou.
You can store tons of data in any HTML5 storage (including IndexedDB or localStorage) and chrome.storage.local with "unlimitedStorage" permission.
HTML5 data is stored per URL origin and each extension has its own one that looks like chrome-extension://id where id is a 32-character string that is the extension's id. In Firefox the origin looks like moz-extension://id.
Extension's own HTML5 storage:
can be accessed in any extension page (popup, options, background) just like you would do it in a web page, there are no differences.
cannot be accessed in a content script as it runs in a web page and thus can only access HTML5 storage of the web page's URL origin.
chrome.storage.local can be accessed in any extension page and in a content script.
No need for special event to create/upgrade your IndexedDB storage - it'll happen automatically if needed - simply open it as shown in the documentation whenever you need to access it and your onupgradeneeded callback will be invoked in case there was no DB or it was outdated.
Use a wrapper library for IndexedDB that provides a simplified syntax. Some are listed in the documentation, but you can probably find better ones yourself.

Getting Specific Data from Post API in WordPress

I want to link my website's Wordpress database to mobile application; and I am able to generate the APIs using wp-json plugin in Wordpress.
However, there is a lot of unwanted data which I do not want for the app. What are the custom parameters in the API url which will help me get only the information I am looking for?
http://www.indiafastener.com/wp-json/wp/v2/posts/2031
PS: I know I can manage & eliminate the unwanted information through the app as well however I do not want to unnecessarily pile up lot of data & do filters in the App.
Thanks for your time.
Utpal
Modern versions of WordPress have the REST API built into core therefore a plugin isn't required.
To check the arguments for an API call, take a look at the documentation. For retrieving a post, see: https://developer.wordpress.org/rest-api/reference/posts/#retrieve-a-post. There are no arguments for limiting the data provided by the response.
While it is possible to modify the response (https://developer.wordpress.org/rest-api/extending-the-rest-api/modifying-responses/), I'd advise against it.
As you pointed out in your question, this data can be managed on the app side. I'd argue that is where you should be dealing with it. It's not about eliminating 'unwanted information' but rather recognising the information you do want.

How do I edit a document in a browser and save it to a database?

I am trying to write a web based application that allows the user to open a document in a browser window and edit it with some sort of editor such as MS Word (any editor will work) and then let the user save the document and have it stored in a database. I can get the document open in the browser window, but I don't know how to save it back to the database. Is this possible? The database is on the server side, not the client side.
Thanks.
This will be pretty tricky to do.
You'd probably need a Word macro or something to detect when the file is saved and then process whatever code on your server would be needed to process it.
My advice would be to use an existing browser-based document editor like Google Documents and hook into its API to do whatever database work you need.
Otherwise this will be tiresomely complex (what editors will you support? can you run arbitrary code against a user's machine? what if they're offline? etc).

Changing Fusion Table Card Layouts Programmatically

While creating a staff database using Fusion Tables and Google Apps Script, I am trying to leverage the existing Fusion Tables UI as much as possible. Cards have been very useful but I am looking for a way that I can programmatically change their layout.
For each entry in the database, a user can upload relevant documents and attach them to an entry. The files are stored in google drive and a link to that document is stored (as an html string) in one of the database fields. Here is a simple image of what that may look like and the layout code to make it.
The problem is that the uploadable files (and fields) are dynamic. The user can add or redefine those fields through my ui and I need the full list of available files on each card to adapt accordingly so I don't have to manually configure the layout each time. How can I create a list of links on the card?
Other background info:
The fusion table will be view only. I haven't figured out a way to validate data entry in the fusion table ui so data entry will be done programmatically and in a custom ui.
I understand that my current method is not very robust and I am very open to other ways of providing access to these files through the card. I've even toyed with the idea of having a general html field for each entry which is programmatically created to display what I want. I'm just hoping there's a better way.
P.S. I've been struggling with reputation limitations for posting links and images. If you think I'm reputable, please help me out.
The problem is that the uploadable files (and fields) are dynamic. The
user can add or redefine those fields through my ui and I need the
full list of available files on each card to adapt accordingly so I
don't have to manually configure the layout each time. How can I
create a list of links on the card?
I may not be exactly following, but it sounds like your app can change the schema for each user? That's what your sample info window HTML seems to show. But that would require a separate table for each app user. If that's not the case then I'm not clear how you are using the term "field".
In any case, the Fusion Tables API does allow you to change template contents, which may solve your problem: https://developers.google.com/fusiontables/docs/v1/reference/template

Calling a Google Drive SDK from Google App Script application

i have been going around in circles here and have totally confused myself. I need some help.
I am (trying to) writing an application for a client that in concept is simple. he want a google write document with a button. the google drive account has several folders, each shared with several people. when he drops a new file in one of the folders, he wants to be able to open this write file, this file is the template for his email. he clicks the button, the system calls the changes service in the Google Drive SDK https://developers.google.com/drive/manage-changes, gets the list of files that have been added since the last time it was checked, then pull the list of people that the file has been shared with, and use the write file as a template to send that list of people an email saying their file is ready.
SO, easy enough, right?
I started by looking at the built in functions in the Google App Script API. I found this method, https://developers.google.com/apps-script/class_docslist#find in the DocsList class. problem is the description for the query simply says "the query string". So at first i tried the Drive SDK query parameters, which are
var files = DocsList.find("modifiedDate > 2012-12-20T12:00:00-08:00.");
it didn't work. that leads me to believe it is a simple full text search on the content. Thats not good enough.
That lead me into trying to call a Drive SDK method from within an App Script application. Great, we need an OLap 2 authentication. easy enough. found the objects in the script reference and hit my wall.
Client ID and Client Secret.
you see, when i create what this really is, a service account, the olap control in apps script doesn't know how to handle the encrypted json and pass it back and forth. Then when i tried to create and use an installed applications key, i get authentication errors because the controls again, don't know what to do with the workflow. and finally, when i try to create a web app key, i can't because i don't have the site host name or redirect URI. And i can't use the application key ability because since im working with files OLap 2 is required.
i used the anonymous olap for a while, but hit the limit of anonymous calls per day in the effort of trying to figure out the code a bit, thats not going to work because the guy is going to be pushing this button constantly thru the day.
i have been pounding my head on the desk over this for 5 hours now. i need some help here, can anyone give me a direction to go?
PS, yes, i know i can use the database controls and load the entire list of files into memory and compare it to the list of files in the database. problem being, we are talking tens of thousands of files. bad idea.
I wouldn't use DocsList anymore - DriveApp is supposed to be a more reliable replacement. Some of the commands have changed, so instead of find, use searchFiles. This should work more effectively (they even use a query like yours as an example).