Blame view

imports/api/documents/methods.js 765 Bytes
d1f05315d   tmcdeveloper   wip adding API an...
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
  import { Documents } from './documents';
  
  export const insertDocument = new ValidatedMethod({
    name: 'documents.insert',
    validate: new SimpleSchema({
      title: { type: String }
    }).validator(),
    run( document ) {
      Documents.insert( document );
    }
  });
  
  export const updateDocument = new ValidatedMethod({
    name: 'documents.update',
    validate: new SimpleSchema({
      _id: { type: String },
      'update.title': { type: String, optional: true }
    }).validator(),
    run( { _id, update } ) {
      Documents.update( _id, { $set: update } );
    }
  });
  
  export const removeDocument = new ValidatedMethod({
    name: 'documents.remove',
    validate: new SimpleSchema({
      _id: { type: String }
    }).validator(),
    run( { _id } ) {
      Documents.remove( _id );
    }
  });