-
Notifications
You must be signed in to change notification settings - Fork 143
Expand file tree
/
Copy pathmodel.js
More file actions
43 lines (37 loc) · 802 Bytes
/
model.js
File metadata and controls
43 lines (37 loc) · 802 Bytes
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
33
34
35
36
37
38
39
40
41
42
43
var MockServer = require('../../mock-server')
var { toJS } = require('nuclear-js')
var ENTITY = 'user'
exports.entity = ENTITY
/**
* @param {User} instance
* @return {Promise}
*/
exports.save = function(instance) {
instance = toJS(instance)
if (instance.id) {
return MockServer.update(ENTITY, instance)
}
return MockServer.create(ENTITY, instance)
}
/**
* @param {Number} id
* @return {Promise}
*/
exports.fetch = function(id) {
return MockServer.fetch(ENTITY, id)
}
/**
* @param {Object?} params
* @return {Promise}
*/
exports.fetchAll = function(params) {
return MockServer.fetchAll(ENTITY, params)
}
/**
* @param {User} instance
* @return {Promise}
*/
exports.delete = function(instance) {
instance = toJS(instance)
return MockServer.delete(ENTITY, instance)
}