-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmodel.js
More file actions
35 lines (32 loc) · 797 Bytes
/
Copy pathmodel.js
File metadata and controls
35 lines (32 loc) · 797 Bytes
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
/*
Each post is represented by a document in the posts collection:
owner: user id
text: String
public: Boolean
comments: Array of objects like {user: userId, text: string}
timestamp: datetime
*/
Posts = new Meteor.Collection("posts");
Posts.allow({
insert: function (userId, text) {
return userId
},
update: function (userId, post) {
return false;
},
remove: function (userId, post) {
return post.owner !== userId;
}
});
var displayName = function (user) {
if (user.profile && user.profile.name)
return user.profile.name;
if (user.username)
return user.username;
return user.emails[0].address;
};
Meteor.methods({
addFriend: function (userId, friend) {
Meteor.users.update(userId, { $addToSet : { friends : friend._id } });
}
});