These are chat archives for Automattic/mongoose

13th
Apr 2015
Mark Herhold
@MarkHerhold
Apr 13 2015 00:22
Can anyone recommend a simple way to perform a healthcheck against a running Mongo server?
One idea I had was to create a healthcheck collection and add a document to a health collection with with a write-concern of 'journaled'.
Ulf Seltmann
@smoebody
Apr 13 2015 11:45
Hello all. since somewhere in v4 mongoose resolves fields of type Schema.ObjectId to the document model of the specified ref. can anyone point me to the issue that introduced this feature?
in 3.8.x it was only the _id of that document.
Pavel Zubkou
@irnc
Apr 13 2015 13:07
@smoebody mongoose does not populate references by default, if in 3.8 you had doc.reference of type ObjectId, and read doc.reference._id after find, it can mean only one thing - reference was populated. Could you please provide code snippet to test?
pdiogo
@PedroMD
Apr 13 2015 15:31
hello everybody!
can anybody tell me the best way to get the latest document of a model ?
its schema is composed of a "created" with has its own timestamp
pdiogo
@PedroMD
Apr 13 2015 15:45
I want to avoid getting ALL documents and then select the latest one at application level... Transferring all these documents from my Mongo MMS to my app is not the optimal solution as it would slow things down overtime...
Ulf Seltmann
@smoebody
Apr 13 2015 16:53
@irnc oh, sorry for the delay..
i made a gist here: https://gist.github.com/smoebody/ec7eebc200b031ec44f5
pdiogo
@PedroMD
Apr 13 2015 18:14
to answer my own question,
Chat.findOne({'from': clientsFirst.to, 'to': socket.username})
.sort({ field: 'asc', _id: -1 })
.limit(1)
.exec(function(err, docs) {
if (err) throw err;
console.log("\nnew test:\n");
console.log(docs);
});
did the trick
Mike Kusold
@Kusold
Apr 13 2015 19:00
I'm looking to update from 3.x to 4.x. Is there a migration guide similar to the 2.x to 3.x guide? http://mongoosejs.com/docs/migration.html
Valeri Karpov
@vkarpov15
Apr 13 2015 23:09
closest thing is 4.0 release notes: https://github.com/Automattic/mongoose/wiki/4.0-Release-Notes . There will be one when 4.0.2 comes out though, migration.html will be replaced with a 3.x to 4.x guide
Tyler Renelle
@lefnire
Apr 13 2015 23:09
Q: I recall seeing somewhere that .find({_id:<parent-id>}).populate('children') adds some efficiency magic over running the equivalent .find({_id:<parent-id>}) + .find({$in:{_id:<children-ids>}}. Is this true? (particularly for multiple population paths, IIRC it constructs fewer queries in the end)