Search code examples
mongodbsocket.iosails.jssails-mongo

What type of Object does publishCreate accept?


When I use:

User.publishCreate(user.id);

My server logs:

error: Invalid usage of publishCreate() :: Values must have an `id`, instead got :: '54fc5ebf4da88b7260445f7d'

My data is being stored in MongoDB that creates an ObjectID. If I use user.id, it is supposed to pass the ObjectID.toString(), but that is not what my publishCreate method takes.


Solution

  • Don't use "id" as attributes, Waterline add you an id automatically or pass it like this User.publishCreate({id:newGuy.id,name:newGuy.name});