These are chat archives for Automattic/mongoose

23rd
Jan 2016
J
@jhyland87
Jan 23 2016 16:43
@alfredopacino did you figure it out?
im new to Mongoose/MongoDB
Whats with the new/edit objects inside:
name: {
        first: { type: String, required: true, forms: {
            new: {},
            edit: {}
        }},
        last: { type: String, required: true, forms: {
            new: {},
            edit: {}
        }}
    }
Dont see that in the schema docs
antonioaltamura
@antonioaltamura
Jan 23 2016 17:38
Hi, sorry tha's confusing those are not proper mongoose fields, I was trying to figure it out how to work with https://www.npmjs.com/package/forms-mongoose, just ignore them
indeed ingnore my previous messages: the specific problem here is in the post :point_up: 23 gennaio 2016 00:33 an instance method works, a static method doesn't!
J
@jhyland87
Jan 23 2016 18:28
Hey guys. So im use to PHP's CodeIgniter and Laravel, where there should be absolutely NO queries run against the database, they should be through models, and you call methods of those models. Is that the same idea as using Mongoose in NodeJS? All queries and interactions should be through the model methods/statics?
J
@jhyland87
Jan 23 2016 21:43
@vkarpov15 Im trying to run a simple query using the population feature you linked to, but im trying to do it with the models being in different files... It doesnt seem to work. the model is here, the property in the schema that is referencing a different collection is the _groups (line40).
I thought that it was failing because maybe that model needed an instance of the Group model, so I loaded it (line 11). But when I load the Group model inside the Account model, it throws an error.
I tried to populate the groups via a query as a model method, as well as a query in its own file, neither work.
And whats really annoying, is the Mongoose errors are just stack traces and point out lines inside the Mongoose library, not my own code/files >.< So its hard to even see what the error is
Im going to follow along on MongoDB's university course, but if you can let me know what im doing wrong sooner, that would be great. Need it for a POC on something, and the university thing takes like a week