These are chat archives for Automattic/mongoose

Mar 2016
Christian Weiss
Mar 28 2016 01:21
is there a way to spin up a new mongodb for each test using mongoose?
  • i use ava + supertest to do functional API testing of an express app that uses mongoose, the tests run in parallel
  • it is possible to use a new express-app instance per test, but all of them seem to use the same single mongoose object and when I try to connect to new DBs I get Error: Trying to open unclosed connection.
Mar 28 2016 08:46
ditch: no idea, but interested in finding out!
Bnaya Peretz
Mar 28 2016 15:22
@vladotesanovic Thanks but it gives me for Mongoose 3.8.5
Mar 28 2016 18:37

Oh great Mongoose Gurus, I have a question.

I have a single document. This single document contains an object. This object contains only objects. Consider:

document = {
  idtfr: 'banana'
  A: {
    0: {...},
    1: {..},

I hope that structure makes sense. Anyway, A can wind up containing well over 100,000 objects. If I modified my query to look like this,
Query .findOne({ idtrf: 'banana' }, { [`A.${objId}`]: 1 }) .then(...),

would I wind up saving any RAM by returning only a partial document? I'm imagining that I would and the savings would be rather large as well, if A contained a large number of objects.

Mar 28 2016 21:51
Actually, this turned out to be an awful idea. Calling .save() on the found document will basically rewrite the entire thing to just the sub-object.