forked from langpavel/baucis-example
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodel.js
More file actions
62 lines (53 loc) · 1.39 KB
/
Copy pathmodel.js
File metadata and controls
62 lines (53 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
// define schema and model
var address = new Schema({
type: String,
street: String,
zip: String,
country: String
}, {_id: false});
var Address = mongoose.model('Address', address);
var user = new Schema({
firstname: String,
salutation: {type: "String", enum: ["Mr.", "Mrs."], required:true},
birthday: Date,
friends: [
{
type: Schema.ObjectId,
ref: 'User'
}
],
addresses: [address]
});
user.options.gform = {labelAttribute: "firstname"}
var User = mongoose.model('User', user);
// define a tab group for the BlogPost administration
var group = {
editor: "tab",
groups: [
{code: "general", label: "General"},
{code: "text", label: "Text"}
]
}
var blogpost = Schema({
title: String,
tags: [String],
rating: Number,
text: { type: String},
author: {
type: Schema.ObjectId,
ref: 'User'
}
}, {gform: {group: group}})
// add additional gform information to the text property.
blogpost.paths.text.options.gform = {
groupCode: "text",
label: "The blog entry",
description: "this should be really interesting stuff.",
editor: "textarea"
};
var BlogPost = mongoose.model('BlogPost', blogpost);
module.exports.BlogPost = BlogPost;
module.exports.Address = Address;
module.exports.User = User;