Kamal Jain
Posts: 0
Joined: Sat Aug 09, 2014 7:37 am

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

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

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

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

Hi Kamal,

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

Kamal Jain7049810
Posts: 0
Joined: Mon Aug 18, 2014 12:52 am

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

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.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

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

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.

Return to “Issues”