Search code examples
javascriptnode.jsdeploydnobackend

Deployd App, dpd.collection.first() not working


I've installed latest version of Deployd on Windows 7 64 Bit. Everything works fine except, I cannot query a single object.

ie, if i use the following code,

var query ={"name":"Jack","empid":"10"};
  dpd.employees.first(query, function (result) {
  console.log(result);
  });

I'm getting TypeError: undefined is not a function at the console (Google Chrome) pointing to the function 'first()'. All other functions generated at the API tab of Dashboard are working fine without any issues. I've tried reinstalling Deployd to another directory & the issue is still there. Haven't tried on a different machine yet.

What might be the cause?

Any help is appreciated.


Solution

  • The first() function was removed from Deployd's dpd.js but they didn't remove(forgot?) the API call codes generated by the dashboard. For now, I've chosen to select a single object using the ID property like this:

    var q = {"id":"00000000000000"};
    dpd.collection_name.get(q,function(result,error) {
     if(error) return console.log(error);
     console.log(result); //Result will have the object with the given ID
    });
    

    Or, if the ID property is not available for some reason, the field name can be used to query the data like usual:

    var q = {"empid":"10AE1",$limit:1}; //Limiting to 1 just to be sure
    dpd.collection_name.get(q,function(result,error) {
     if(error) return console.log(error);
     console.log(result[0]); //result[0] will have the object with the given empid
    });
    

    If there are any better solutions, please let me know!