-2

I have a hand-made collection (mymodel) in MongoDB. I have created a sails model+controller using 'sails generate api mymodel'

I am now trying to use the sails find() method using the REST api: http://localhost:1377/mymodel, but I do not get any data returned. I have even tried to write my own end-point method and used the Waterline ORM find() method, but still don't get anything returned.

Am I missing something? Is there something more to be done?

  1. Its a simple model, like {A:123,b:"wf"}
  2. No specific data pieces
  3. From mongo shell, I get the complete information
Travis Webb
  • 14,688
  • 7
  • 55
  • 109
user1749672
  • 116
  • 1
  • 8
  • 1
    1. how does your model look exactly? 2. How exactly does the data look which you inserted into your collection? 3. what do you get when you connect to your MongoDB with the `mongo` shell and perform a `find()` on your collection? – Philipp May 04 '15 at 11:24
  • 1. Its a simple model, like {A:123,b:"wf"} 2. No specific data pieces 3. From mongo shell, I get the complete information – user1749672 May 04 '15 at 11:48
  • 1
    Please don't answer to me directly. Update your question instead. – Philipp May 04 '15 at 11:48

1 Answers1

1

Found the problem. If a create a collection using the name "MyModel" in MongoDB, and then create a controller+model in sails.js (sails generate api MyModel), sailsjs does not seem to use the "MyModel" collection, but rather tries to create a new collection completely in lower case ("mymodel") where all the transactions are committed.

So the trick is to create a collection in lowercase only so that sails starts using it

Not sure if this is a bug in sails.js

user1749672
  • 116
  • 1
  • 8