These are chat archives for Automattic/mongoose

8th
Apr 2016
Diego Aguilar Aguilar
@diegoaguilar
Apr 08 2016 16:27
how can Mongoose synchronously create a mock document with an ObjectId making sure it won't conflict with remote DB is connected to? I mean let newUser = new User();
Pier-Luc Gagnon
@Nepoxx
Apr 08 2016 17:06
when you connect to mongo, you're assigned a starting id, and you increment from there
Diego Aguilar Aguilar
@diegoaguilar
Apr 08 2016 18:15
but technically speaking ... what if more mongoose instances are connected @Nepoxx
Pier-Luc Gagnon
@Nepoxx
Apr 08 2016 18:15
It's a mongodb feature
So when you connect to mongo, mongo tells you "ok, start your IDs at 54g9dj01"
if another instance connects, it'll say something like ""ok, start your IDs at hg73d01"
Diego Aguilar Aguilar
@diegoaguilar
Apr 08 2016 19:16
ohh :)
that wat a conflict wont happen
paulgrove
@paulgrove
Apr 08 2016 21:43
Hey guys, I've not used mongoose before, but I've been reading the docs for a while. There is something I would like to try and work out.
I want to write a plugin that checks a user's roles and permissions based on their session (express). How can I instance the schema and load the plugins on a per session basis without creating a mongoose connection for each user?
paulgrove
@paulgrove
Apr 08 2016 22:03
If im not mistaken, I'll have to create a full set of schema objects (and load the plugin(s)) for each connection?
or am I missing a trick?
paulgrove
@paulgrove
Apr 08 2016 23:11
I have another question, how does unique work? where is it documented? I can't find it...
presumably it has to create an index
Searching the site I can see references to it in old documentation, I guess unique has been removed?