-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathedit.examples.js
31 lines (26 loc) · 936 Bytes
/
edit.examples.js
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
'use strict';
const { log, store } = require('./services');
//#edit-record-example
const editRecord = client =>
client
.find('Heroes', [{ name: 'Anakin Skywalker' }], { limit: 1 })
.then(response => response.data[0].recordId)
.then(recordId => client.edit('Heroes', recordId, { name: 'Darth Vader' }))
.then(result => log('edit-record-example', result));
//#
//#edit-record-merge-example
const editRecordMerge = client =>
client
.find('Heroes', [{ name: 'Anakin Skywalker' }], { limit: 1 })
.then(response => response.data[0].recordId)
.then(recordId =>
client.edit('Heroes', recordId, { name: 'Darth Vader' }, { merge: true })
)
.then(result => log('edit-record-merge-example', result));
//#
const edits = (client, examples) =>
Promise.all([editRecord(client), editRecordMerge(client)]).then(responses => {
store(responses);
return client;
});
module.exports = { edits };