Blame view

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