Teambition Core Schema
引用此项目并作为一个基础Teambition Schema库.
Usage
'use strict'
var limbo = require('limbo')
var mongoose = require('mongoose')
var tbSchema = require('tb-schema')
var DB_URL = 'mongodb://root:root@192.168.0.21:27017/teambition?replicaSet=rs0'
var options = {
auth: {
authdb: 'admin'
}
}
mongoose.connect(DB_URL, options)
var db = limbo.use('teambition', {
provider: 'mongo',
conn: mongoose.connection
})
var schemas = tbSchema.schemas(mongoose.Schema)
db.loadSchemas(schemas)
module.exports = db
API
schemas(Schema)
return all schemas that instanceof Schema.
var schemas = tbSchema.schemas(mongoose.Schema)
var userSchema = schemas.user
getSchema(Schema, name)
return base schemas that instanceof Schema.
var userSchema = tbSchema.getSchema(mongoose.Schema, 'user')