Page 1 of 1

How do I make one entry per device in my databases? I want the same entry to be updated instead of new entry getting cre

Posted: Sun Aug 17, 2014 6:02 am
by Kamal Jain

Bascially, input from every device using my app should be only in one entry. Same entry getting updated over and over again.


How do I make one entry per device in my databases? I want the same entry to be updated instead of new entry getting cre

Posted: Sun Aug 17, 2014 9:13 am
by Illya Stepanov

Hi Kamal,

Please clarify with more details, what do you want to implement as it's not very clear now.


How do I make one entry per device in my databases? I want the same entry to be updated instead of new entry getting cre

Posted: Mon Aug 18, 2014 12:52 am
by Kamal Jain7049810

I want to have a unique number given off to every device, so that when they give an input, it is stored in the database with the number.
When they put an input again, I wan't a javascript command to check for the numeber in the database and update it if is already there or else create it.


How do I make one entry per device in my databases? I want the same entry to be updated instead of new entry getting cre

Posted: Mon Aug 18, 2014 3:23 am
by Yurii Orishchuk

Hi Kamal,

Here is brief plan for you:

1 create collection with field "deviceId".

2 get deviceId in way you like.

3 make "query" request to the collection with "where" parameter "{deviceId: xxxxx}". Where xxx your deviceId from 2nd step.

4 on "success" event for this query service you need to check count of returned items. Code example:

pre

var count = data.length;

if(count == 0)
alert("there is no items with this deviceId")
else
alert("here is item with this deviceId");

/pre

5 then you can make other actions in accordance to your app logic.

Regarsd.