These are chat archives for Automattic/mongoose

25th
Jul 2015
Felix Milea-Ciobanu
@felixmc
Jul 25 2015 02:21
is there a way to embed schemas in other schemas directly, without refs?
my use case is that I have a User model, and a User may or may not have a "profile" property. If it does, I want the profile object to be according to a specific schema (validation/required/default rules), if not it woudl just be undefined on the User object
Joseph Thibeault
@jrthib
Jul 25 2015 18:36
can you have default values set on nested objects in a schema such as:
var Schema = {
    something: {
        prop1: { default: 0 }
    }
}
I’ve been trying to do that, but it doesn’t seem to be working
also, not sure if thats kosher in the sense of good schema design. We’ve just been using it as a way of organizing data.
Johny Georges
@JetJet13
Jul 25 2015 19:03
Hello, is anyone here. I have a question.
Joseph Thibeault
@jrthib
Jul 25 2015 19:03
im here
Johny Georges
@JetJet13
Jul 25 2015 19:03
hi there
Joseph Thibeault
@jrthib
Jul 25 2015 19:04
im not a mongoose maintainer but i may be able to help
Johny Georges
@JetJet13
Jul 25 2015 19:04
I'm trying to connect to the local database when I started the instance with mongod --auth
I created a user in the admin database with : roles [{role:'readwrite', db:'local'}]
Johny Georges
@JetJet13
Jul 25 2015 19:13
in other words, how do I authenticate into the local database ?
Joseph Thibeault
@jrthib
Jul 25 2015 19:49
oh
you should just have to update your connection string with the user
mongodb://username:password@localhost:27017/databasename
something like that
Johny Georges
@JetJet13
Jul 25 2015 19:51
that's what I have been trying. mongod keeps telling me that 'username' is not a user of local... auth. failed.
Johny Georges
@JetJet13
Jul 25 2015 20:44
mongodb://username:password@localhost:27017/databasename?authSource=admin
appears to work.
Joseph Thibeault
@jrthib
Jul 25 2015 22:31
Ah makes sense, you'd have to tell it where the auth collection is. I believe there may be a mongo config setting where you can tell it a default auth source.