These are chat archives for Automattic/mongoose

27th
Apr 2016
Albert Szekely
@pixeldublu
Apr 27 2016 11:51
hi guys
any example query on updating a subdocument ? ( i know the id of both document and subdocument )
db.collection.update( { "_id" : ObjectId("5719fe21e78b06f20616ee00"), "consumers.id" : ObjectId("572072e4260cd05e07e5df30") }, { $set : { "consumers.$.email" : "update@mongo.db" } }, false, true )
got something like this but does not work :(
objectids are correct
sry not really mongoose problem
Vlado Tesanovic
@vladotesanovic
Apr 27 2016 13:02
@pixeldublu Array of documents or sub document, if it is sub document, than you can with consumers.email
pixelul
@pixelul
Apr 27 2016 13:04
consumers is subschema
consumers: [Consumerslist] this is in model declaration
but i belive cannot even find
db.emaillists.find( { "_id" : ObjectId("5719fe21e78b06f20616ee00"), "consumers.id" : ObjectId("572072e4260cd05e07e5df30") } )
no result
Vlado Tesanovic
@vladotesanovic
Apr 27 2016 13:08
@pixelul === @pixeldublu ?
pixelul
@pixelul
Apr 27 2016 13:12
yes
one is personal the other is work :))
is there any software to connect to mongo ( similar to robomongo ) that also shows you queries ? (Ex: i delete something and show me the query of deletion like phpmyadmin :) )
Vlado Tesanovic
@vladotesanovic
Apr 27 2016 14:23
@pixelul copy document from database here, using this
{
 "key": "vlue
}
Ean McLaughlin
@computertechie
Apr 27 2016 14:48
Is there some conflict with setting the timestamps option on the base model of a discriminator?
I was trying to do it last night and was getting:
d:\planetside\planetside-server\node_modules\planetside-database\node_modules\mongoose\lib\utils.js:390
    if (typeof to[key] === 'undefined') {
                 ^

TypeError: Cannot read property 'background' of null
Ean McLaughlin
@computertechie
Apr 27 2016 15:02
where the schema is defined as:

var options = {discriminatorKey: 'event_name', timestamps: true};

var Event = new mongoose.Schema({
        timestamp: {type: Date, index: true},
        world_id: {type: Number, ref: 'World', index: true},
        zone_id: {type: Number, index: true}
    },
    options
);
Event.path('createdAt').expires('3 days');
Valeri Karpov
@vkarpov15
Apr 27 2016 17:17
@vladotesanovic yep lean() is all about better performance. Mongoose has a non-negligible amount of overhead
@computertechie hmm can you open up an issue for this on github? https://github.com/Automattic/mongoose/issues/new shouldn't be anything wrong with that but you may well have stumbled on a bug
Ean McLaughlin
@computertechie
Apr 27 2016 18:39
@vkarpov15 sure
I'll do some tests first; I'm using mongoose-fill so that may be causing it