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