{username: 'me', company: {"yourcompany": {...}
I want to insert a company in a user record (user collection) to do:
{username: 'me', company: {"yourcompany": {...}, "mycompany": {...}}
But the name is dynamic.
var companyid = "mycompany";
.collection('users').findAndModify(
{username: usern},
[['_id', 'asc']],
{$set:{companies:{companyid: { desksmemberships:[] }}}},
{new: true}, function(){...}
Gives it .. {username: 'me', company: {"yourcompany": {...}, "companyid": {...}}
How to do it?
source
share