Getting started
Installing
$ npm install Blini --saveImporting
import { Schema, Model, Validation, Type, Connection } from 'Blini'Create a connection to MongoDB
const connection = new Connection('mongodb://localhost:27017/myproject');Create a schema
const userSchema = new Schema({
username: Type.String({
validation: [
Validation.required(),
Validation.minLength(3, 'Username should be 3 characters min'),
Validation.maxLength(30, 'Username should be 40 characters max')
],
index: {
unique: true
}
}),
books: Type.Set(Type.Ref('Book'), {
validations: [
Validation.default([]),
]
})
})Create a new document model
Create new documents
Query the collection
Last updated