
Untitled
By: a guest on
Apr 24th, 2012 | syntax:
None | size: 1.79 KB | hits: 15 | expires: Never
Creating query(join) or correct the design?
// User, the profile is not complete there will be more fields
var u = {
name: 'Michael', // Is not unique
email: 'mo@gmail.com', // Should be also unique
fbid: '4545454asdadsa'
}
db.user.insert(u);
// User can have 0 to many posts
var p = {
title: 'Suprise',
body: 'Well done',
tags: ['first', 'post', 'english'],
author: 'mo@gmail.com',
created: new Date(),
modified: new Date()
};
db.post.insert(p);
var p = {
title: 'Weather in Estonia',
body: 'Always looks bad',
tags: ['bad', 'weather', 'estonia'],
author: 'mo@gmail.com',
created: new Date(),
modified: new Date()
}
db.post.insert(p);
var p = {
title: 'Suprise',
body: 'Well done',
tags: ['first', 'post', 'english'],
author: {
name: 'Michael', // Is not unique
email: 'mo@gmail.com', // Should be also unique
fbid: '4545454asdadsa'
},
created: new Date(),
modified: new Date()
};
{
title: String,
body: String,
tags: [String],
author: {
name: String,
email: String,
fbid: String
},
created: Date,
modified: Date,
comments: [{
body: String,
created: Date,
modified: Date
}]
}
{
name: String,
email: String,
fbid: String,
posts: [{
title: String,
body: String,
tags: [String],
created: Date,
modified: Date,
comments: [{
body: String,
created: Date,
modified: Date
}]
}]
}
{
body: String,
created: Date,
modified: Date,
author: {
name: String,
email: String,
fbid: String
},
post: {
title: String,
body: String,
tags: [String],
created: Date,
modified: Date
comments: [{
body: String,
created: Date,
modified: Date
}]
}
}