Blame view
imports/api/documents/methods.js
882 Bytes
d1f05315d
|
1 |
import { Documents } from './documents'; |
cac7cbc73
|
2 3 |
import { SimpleSchema } from 'meteor/aldeed:simple-schema'; import { ValidatedMethod } from 'meteor/mdg:validated-method'; |
d1f05315d
|
4 5 6 7 |
export const insertDocument = new ValidatedMethod({ name: 'documents.insert', validate: new SimpleSchema({ |
f0c912bf1
|
8 |
title: { type: String }, |
d1f05315d
|
9 |
}).validator(), |
f0c912bf1
|
10 11 12 |
run(document) { Documents.insert(document); }, |
d1f05315d
|
13 14 15 16 17 18 |
}); export const updateDocument = new ValidatedMethod({ name: 'documents.update', validate: new SimpleSchema({ _id: { type: String }, |
f0c912bf1
|
19 |
'update.title': { type: String, optional: true }, |
d1f05315d
|
20 |
}).validator(), |
f0c912bf1
|
21 22 23 |
run({ _id, update }) { Documents.update(_id, { $set: update }); }, |
d1f05315d
|
24 25 26 27 28 |
}); export const removeDocument = new ValidatedMethod({ name: 'documents.remove', validate: new SimpleSchema({ |
f0c912bf1
|
29 |
_id: { type: String }, |
d1f05315d
|
30 |
}).validator(), |
f0c912bf1
|
31 32 33 |
run({ _id }) { Documents.remove(_id); }, |
d1f05315d
|
34 |
}); |