0

I've an application with sails.js and mongodb.

The sails rest api works fine for create. It also works fine when I access it as "http://localhost:1337/student" but not working when finding a specific document with id "http://localhost:1337/student/54e57a98469768d40df7fb24".

The object id in db is stored as _id : ObjectId("54e57a9e469768d40df7fb25").

I also tried to update record in Controller but that also seems to be NOT working:

Student.update({id:Student.mongo.objectId(req.body.id)},{is_active:0}).exec(function(err, data){ ............ }); Any help will be appreciated.

Thanks.

1 Answer 1

1

I do notice your ids are different between your URL and the mongo paste, so make sure that is on. Also I'd recommend installing the postman packaged app in the google chrome store, its really nice for doing rest work. If you watch the sailscasts videos by nathanirl on YouTube you'll see some nice examples of what it can do.

Also make sure your blueprints.js in config file is setup with. Actions, shortcuts and rest set to true

2
  • Thanks for the answer. Actually the issue was not IDs. I was mapping id with _id in my model. I removed that mapping and it started working. Mar 12, 2015 at 6:53
  • Glad to hear you found it!
    – zabaat
    Mar 13, 2015 at 9:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.