1

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.

Matias Faure
  • 822
  • 1
  • 9
  • 20
  • Docs for `publishCreate` are [here](http://sailsjs.org/#!/documentation/reference/websockets/resourceful-pubsub/publishCreate.html). – sgress454 Mar 09 '15 at 19:35

2 Answers2

1

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});

dkx22
  • 1,103
  • 1
  • 13
  • 25
0

As stated in the documentation, publishCreate method expects an object, and you are passing in a scalar value. Ideally, you just pass in a newly-created User object, but if you want to restrict what gets sent you can construct the object yourself as in @dkx22's example.

sgress454
  • 24,870
  • 4
  • 74
  • 92