Skip to content

Instantly share code, notes, and snippets.

@bitdewy
Created March 12, 2014 17:30
Show Gist options
  • Save bitdewy/9511929 to your computer and use it in GitHub Desktop.
Save bitdewy/9511929 to your computer and use it in GitHub Desktop.
xocean schema
// !!! sketch, no constraint
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
var WorkItemSchema = new Schema({
description: String,
createdAt: Date,
lastModified: Date,
status: Number
});
// no comment on comment so far
var CommentSchema = new Schema({
username: String,
content: String
});
var TagSchema = new Schema({
name: String,
description: String
})
var ArticleSchema = new Schema({
title: String,
body: String,
createdAt: Date,
lastModified: Date,
comments: [CommentSchema],
tags: [TagSchema],
status: Number
});
var UserSchema = new Schema({
name: String,
email: String,
role: {
type: String,
default: 'user'
},
hashedPassword: String,
provider: String,
salt: String,
facebook: {},
twitter: {},
github: {},
google: {},
group: Number,
employeeID: String,
works: [WorkItemSchema],
articles: [ArticleSchema]
});
@meterler
Copy link

@bitdewy
那还是单独的吧,不过还是得加个字段区分下上周还是下周吧

@ijse
Copy link

ijse commented Mar 14, 2014

@bitdewy

不是那么简单的原则。。 其实我觉得设计的时候需要各种权衡,最重要的是要跟业务结合,有过一些经验,设计的时候就可以避免走一些弯路。

可以去参考下其它开源项目的源码,很多的。

那个数据库设计的三泛式其实在这里不是特别适合。

@ijse
Copy link

ijse commented Mar 14, 2014

@meterler @bitdewy

相关xOcean的讨论,以后还是到teambition上吧,这样也便于以后整理和回顾。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment