Page 1 of 3

I need to have new db copy made for every app install

Posted: Fri Jun 20, 2014 12:48 pm
by Dave Troxel

Each time a user downloads and installs my app, I need them to get a new and dedicated database with tables already built and one example row in each table. How do I do this and does Appery host the databases?


I need to have new db copy made for every app install

Posted: Fri Jun 20, 2014 2:01 pm
by Evgene Karachevtsev

Hello Dave,

There is no possibility to create a personal database for each user. Could you please clarify why don't you want to store data for all users in one ot the collections of database in Appery.io


I need to have new db copy made for every app install

Posted: Fri Jun 20, 2014 2:38 pm
by Dave Troxel

Each user of the app needs to maintain a personal list of their own that is not shared with every user of the application.


I need to have new db copy made for every app install

Posted: Fri Jun 20, 2014 6:43 pm
by Kateryna Grynko

Hi Dave,

Just add a field 'owner' to a collection where you store user id, and then use a parameter 'where' to obtain the user data: http://devcenter.appery.io/documentat...


I need to have new db copy made for every app install

Posted: Mon Jun 23, 2014 7:40 pm
by Dave Troxel

Though this example shows me how to create a user. It doesn't show me anything about the where parameter. Can you provide an example of how and where I would place the 'where' parameter and it's criteria? Thanks.


I need to have new db copy made for every app install

Posted: Mon Jun 23, 2014 11:17 pm
by Yurii Orishchuk

Hi Dave.

Lets assume: in your collection you have field "owner".

This field fills with user "_id" who created this row in collection.

When you need to get all user(with certain "_id") rows you need to make following:

1 Add to your page "query" service for collection you need. http://prntscr.com/3vu3gc/direct

2 Click "Edit mapping".

3 Navigate to "Request" tab and you will see "Where" request parameter. http://prntscr.com/3vu5hi/direct

4 You can map directly "LSV" to this field. http://prntscr.com/3vu69b/direct

5 Then click "Add JS" and fill it with following code:

pre

var where = {"owner": value};

return JSON.stringify(where);

/pre

http://prntscr.com/3vu9z1/direct

So you need fill this parameter with current user "_id" and this service will return only items with this id.

Regards.


I need to have new db copy made for every app install

Posted: Thu Jun 26, 2014 3:14 pm
by Dave Troxel

Do I need to put an 'owner' field (column) in each collection they will be using? I am assuming so. I have two collections they will use.


I need to have new db copy made for every app install

Posted: Thu Jun 26, 2014 4:45 pm
by Dave Troxel

Ok, the last step number 5 ... I added the script to the 'Where' request parameter JS Add. ... however, I am still seeing all items on list by both logins. Please help.


I need to have new db copy made for every app install

Posted: Thu Jun 26, 2014 11:22 pm
by Yurii Orishchuk

Hi Dave,

Please make the following screen shots:

1 Your DB collection.

2 Service request mapping.

3 Service request mapping "where" add js code.

Regards.


I need to have new db copy made for every app install

Posted: Thu Jun 26, 2014 11:43 pm
by Dave Troxel

You won't be able to see all the columns with screen shots. There are two collections in the Med_DB being used: MedsColl and DocsColl.

I have added the column 'owner' to both but have not built out the mappings for DocsColl as of yet. Only working with MedsColl to get it working.

I will share the app with you for you to review when you can please.