Closed johntom closed 9 years ago
That is because I have disabled all other globals that sails itself. See backend/config/globals.js for more information.
So basically Book.find() => sails.models.book.find() should work.
Thanks again, I've spent the bulk of my sails time in version 0.10.5 so I'm a bit behind and will start reading more about 0.11. So either
sails.models.book.find().exec(function (err, books) {
if (err) return res.negotiate(err);
return res.json(books);//{'data':todos});
});
or chaning models:true in globals.js does the trick and
Book.find().exec(function (err, books) {
Yep, i recommend that you disabled all but sails on those globals and then just use sails.models.foobar.find() or sails.services.yourservice.method()
This is basically sails related stuff nothing todo with my repo....
Hi, I'm having an issue adding a custom route, something I routinely do when using my repo and I'm not sure why I get the referrence error "model[Book] is not defined" when it hits the route http://localhost:1337/booktest?token=eyJhbGciOiJIUzI1NiJ9.Mg._bgkwMqrKxFvVhupixHLIfvF5WpbihENyFpTQN5Eito
Thanks, John
If I add the following route 'GET /booktest': 'BookController.booktest' and method to BookController module.exports = .merge(.cloneDeep(require('../base/Controller')), { booktest: function(req, res) { console.log('books.........'); Book.find().exec(function (err, books) { if (err) return res.negotiate(err); return res.json(books);//{'data':todos}); }); } });
console