These are chat archives for Automattic/mongoose

8th
Feb 2016
Jonathan Crockett
@jonascript
Feb 08 2016 02:47
Hi, the plugin site seems to be down...http://plugins.mongoosejs.com/
Guy Nesher
@gnesher
Feb 08 2016 13:05
Hi guys, I'm new to mongoose and trying to do a bulk insert using collection.insert - however it fails on duplicates even though I've set { ordered: false }
Any ideas what I'm doing wrong?
Guy Nesher
@gnesher
Feb 08 2016 13:22
Anyone actually alive ? :)
Sebastien Vaucouleur
@vaucouleur
Feb 08 2016 13:23
@jonascript Yes, I reported this as well recently, but this was already tracked here Automattic/mongoose#3127
Guy Nesher
@gnesher
Feb 08 2016 13:24
Intersting - though this seems to be a core mongoose bug :/
Jonathan Crockett
@jonascript
Feb 08 2016 15:42
@vaucouleur Thanks I bumped. Too bad. Want to use plugins for a big project but can't really if the sites down :(
J
@jhyland87
Feb 08 2016 15:44

Hey guys, I was wondering if you could help me with a query.... Heres an example document from a collection:

{
    "_id" : ObjectId("56b7d923fa231e4606a59c29"),
    "_partition" : ObjectId("56ae4707f3d4645b2e5b0537"),
    "attributes" : [
        {
            "_field" : ObjectId("56ae4703f3d4645b2e5b0534"),
            "value" : "server-04.server.ad",
            "_id" : ObjectId("56b7d923fa231e4606a59c2c")
        },
        {
            "_field" : ObjectId("56ae4703f3d4645b2e5b0535"),
            "value" : "Test Server # 04",
            "_id" : ObjectId("56b7d923fa231e4606a59c2b")
        },
        {
            "_field" : ObjectId("56ae4703f3d4645b2e5b0536"),
            "value" : true,
            "_id" : ObjectId("56b7d923fa231e4606a59c2a")
        }
    ],
    "__v" : 0
}

Now would there be a way to select all documents that have an attributes._field = 'someId' ?

Oh I think I got it, checking :-D
J
@jhyland87
Feb 08 2016 15:56

Maybe not.. I tried:

Asset.find({ _partition: '56b7d923fa231e4606a59c29', 'attributes._field': '56ae4703f3d4645b2e5b0534' })

Just returns empty

J
@jhyland87
Feb 08 2016 16:04
Nevermind, I got it :)
Matthew Adams
@matthewadams
Feb 08 2016 21:27
Can anyone tell me why, when I retrieve a document from the db, nested documents are simple JavaScript objects and not instances of Model, complete with instance methods that I've customized the schema with?
J
@jhyland87
Feb 08 2016 22:52
Is it possible to query for documents, based on the populated value of a subdoc? Example:
this.find( {
     _partition: partitionId,
    'attributes._field.name': field
} )
    .populate( { path: 'attributes._field' } )
I cant seem to get it to work
This is driving me crazy
J
@jhyland87
Feb 08 2016 23:01

I was looking at doing it like this instead:

this.find( {
    _partition: partitionId
} )
    .populate( {
        path: 'attributes._field' ,
        match: { name: { $eq: field } }
    } )

But that would find ALL documents with the partition matching, then just populate the attributes._field values if the name matches, but if it doesnt match... it would still include the document right?... thats not what I want