adding schemas

This commit is contained in:
Sacha Greif 2014-05-10 16:57:17 +09:00
parent b04d727335
commit d073a6dfd3
4 changed files with 165 additions and 0 deletions

View file

@ -1,5 +1,52 @@
Comments = new Meteor.Collection('comments');
// Comments = new Meteor.Collection("comments", {
// schema: new SimpleSchema({
// body: {
// type: String,
// },
// baseScore: {
// type: Number
// },
// score: {
// type: Number
// }
// baseScore: {
// type: Number
// },
// upvotes: {
// type: Number
// },
// upvoters: {
// type: []
// },
// downvotes: {
// type: Number
// },
// downvoters: {
// type: []
// }
// score: {
// type: Number
// },
// author: {
// type: String
// },
// inactive: {
// type: Boolean
// },
// createdAt: {
// type: Date
// },
// postId: {
// type: "???"
// },
// userId: {
// type: "???"
// }
// })
// });
Comments.deny({
update: function(userId, post, fieldNames) {
if(isAdminById(userId))

View file

@ -1,5 +1,25 @@
Notifications = new Meteor.Collection('notifications');
// Notifications = new Meteor.Collection("notifications", {
// schema: new SimpleSchema({
// properties: {
// type: Object
// },
// event: {
// type: String
// },
// read: {
// type: Boolean
// },
// createdAt: {
// type: Date
// },
// userId: {
// type: "???"
// }
// })
// });
Notifications.allow({
insert: function(userId, doc){
// new notifications can only be created via a Meteor method

View file

@ -1,5 +1,66 @@
Posts = new Meteor.Collection('posts');
// Posts = new Meteor.Collection("posts", {
// schema: new SimpleSchema({
// headline: {
// type: String,
// label: "Title",
// },
// url: {
// type: String,
// label: "URL"
// },
// body: {
// type: String,
// },
// author: {
// type: String
// },
// comments: {
// type: Number
// },
// baseScore: {
// type: Number
// },
// upvotes: {
// type: Number
// },
// upvoters: {
// type: []
// },
// downvotes: {
// type: Number
// },
// downvoters: {
// type: []
// }
// score: {
// type: Number
// },
// status: {
// type: Number
// },
// createdAt: {
// type: Date
// },
// submitted: {
// type: Date
// },
// sticky: {
// type: Boolean
// },
// inactive: {
// type: Boolean
// },
// categories: {
// type: []
// },
// userId: {
// type: "???"
// }
// })
// });
STATUS_PENDING=1;
STATUS_APPROVED=2;
STATUS_REJECTED=3;

View file

@ -1,3 +1,40 @@
var Schema = {};
Schema.User = new SimpleSchema({
_id: {
type: String,
regEx: SimpleSchema.RegEx.Id
},
username: {
type: String,
regEx: /^[a-z0-9A-Z_]{3,15}$/
},
emails: {
type: [Object]
},
"emails.$.address": {
type: String,
regEx: SimpleSchema.RegEx.Email
},
"emails.$.verified": {
type: Boolean
},
createdAt: {
type: Date
},
profile: {
type: Schema.UserProfile,
optional: true
},
services: {
type: Object,
optional: true,
blackbox: true
}
});
// Meteor.users.attachSchema(Schema.User);
Meteor.users.allow({
update: function(userId, doc){
return isAdminById(userId) || userId == doc._id;