These are chat archives for Automattic/mongoose

Feb 2016
Konstantin Baierer
Feb 15 2016 11:55
@jhyland87 Setting up and tearing down a mongodb for testing isn't that complicated. you can use npm pretest/posttest for that and will work with TravisCI.
Feb 15 2016 14:58
@kba Right, but id like to not assume theres going to be mongodb installed locally, and id like to not have to require for anyone who downloads it, to install it, and/or setup a connection
Im using mongolab atm
And I got mockgoose working actually.... The problem Im having is actually with spy, so my bad
and @kba is TravisCI like JenkinsCI? I use Jenkins a lot at work
(Im a linux/infrastructure/security engineer, not a developer, but I work with developers a lot)
ohh, travisci is 3rd party only, eh
looks nice tho
Feb 15 2016 15:42
guys if I want to allow the users to do an advanced search of all possible field of a document I have to set index:true in each field of the schema? Do you think it's a good pratice? What about the refs fields?
Konstantin Baierer
Feb 15 2016 16:08
@jhyland87 travisCI works fine and is well supported and free for open source, so far I'm happy with that.
Feb 15 2016 16:10
yeah it looks pretty cool. I use it for more than just CI, I use it basically as a web UI for non-techy people to be able to login and execute bash/perl/pythin/etc scripts from the UI
Konstantin Baierer
Feb 15 2016 16:10
@alfredopacino Have you considered a fulltext wildcard index?
Feb 15 2016 16:17

If I understood right wildcard index allows to index all text fields, right? it could be useful, but what about a referenced field?

var com_user_schema = new Schema({
    name: { type: String, required: true },
    age: {type:Number, required:true}

var com_user= mongoose.model('com_user', com_user_schema);

var reg=new Schema({number: Number, year: Number});
var com_post_schema = new Schema({
    content: { type: String, required: true },
    postedBy: [{
        type: mongoose.Schema.Types.ObjectId,
        ref: 'com_user'
var com_post= mongoose.model('com_post', com_post_schema);

If I want to find all the posts by username (postedBy field is an array)?
clearly it's a simplified example, my real documents have 30 fields and 15 refs each.
I'm a little worried about the performance of those queries.

Feb 15 2016 18:19
Hey. Was gonna ask for some opinions. Some of my schemas require a updatedBy and createdBy attributes. I didnt want to have to manually hand these down from function to function to function, til eventually it gets to the model. Does anyone have an idea of how account data can be stored and retrieved later? I was thinking global variables, as much as I hate using them, and ive always tried to stay away from them, it seems like this may be an acceptable situation
Feb 15 2016 19:29
Hey guys - what would be the nicest way of using if in a pipe query?
second .where is optional, depending on user input

.if(condition, where('status').equals(

i'd live somethink good readable like - any tips?

Feb 15 2016 23:51
@jhyland87 maybe it could be useful, I'm not sure I understood the question
var mySchema = mongoose.Schema({
}, { timestamps: { createdAt: 'createdAt' }});