-
Notifications
You must be signed in to change notification settings - Fork 119
Defining and Accessing a Model
Alexey Gordeyev edited this page Apr 7, 2015
·
1 revision
Models are defined through the Schema
interface.
// define models
var Post = schema.define('Post', {
title: { type: schema.String, limit: 255 },
content: { type: schema.Text },
params: { type: schema.JSON },
date: { type: schema.Date, default: Date.now },
published: { type: schema.Boolean, default: false, index: true }
});
// simplier way to describe model
var User = schema.define('User', {
name: String,
bio: schema.Text,
approved: Boolean,
joinedAt: Date,
age: Number
});
// models also accessible in schema:
schema.models.User;
schema.models.Post;