These are chat archives for Automattic/mongoose

5th
Jan 2016
James Lee
@uptownhr
Jan 05 2016 17:40
@vkarpov15 goosecon is pretty cool!
Joseph Thibeault
@jrthib
Jan 05 2016 20:36
hey guys, i’m browsing around on npm and can’t seem to find a good mongoose pagination plugin that implements ranged pagination. any recommendations?
it seems like it’s a big thing when using mongo, yet none of the plugins i’ve found are very popular
SanderV1992
@SanderV1992
Jan 05 2016 21:15
hi
is some body who can help me a little bit with mongo - mongoose, please. Just a little bit.
Joseph Thibeault
@jrthib
Jan 05 2016 21:16
i can try, what’s your question
SanderV1992
@SanderV1992
Jan 05 2016 21:17
I am glad to hear you,
question is simple.
var Schema = new mongoose.Schema({ age: { type: Number, default: 0, min: 5, max: 20 } });
how can I use min and max filter, to make Schema with age. for example from 5 to 20.
right now it dosent work, I put age 9999 and result is 9999
Joseph Thibeault
@jrthib
Jan 05 2016 21:18
min and max are validators that run when you create a new document, not a schema
you also need to register that schema mongoose so you can use it to create documents
Tim Elfelt
@timelf123
Jan 05 2016 21:19
min: needs to be an array like so:
var min = [10, 'The value of path{PATH}({VALUE}) is beneath the limit ({MIN}).']; var schema = new Schema({ n: { type: Number, min: min })
SanderV1992
@SanderV1992
Jan 05 2016 21:24

```var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');

var Schema = new mongoose.Schema({
age: {
type: Number,
min: 5
}
});

var Cat = mongoose.model('Cat', Schema);

var kitty = new Cat({
age: 4
});

console.log(kitty);```

Tim Elfelt
@timelf123
Jan 05 2016 21:25
below mongoose.connect('mongodb://localhost/test'); add var min = [10, 'The value of path{PATH}({VALUE}) is beneath the limit ({MIN}).']; to set the minimum age to 10
and change 5 to min
SanderV1992
@SanderV1992
Jan 05 2016 21:27
hmm
nothing, looks like same isue, I can send less then 10 numbers.
dont know maybe I am dump
(