generated from yaakov-hatam/cellphones-restful-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathphonebl.js
More file actions
59 lines (53 loc) · 1.32 KB
/
phonebl.js
File metadata and controls
59 lines (53 loc) · 1.32 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
delete require.cache[require.resolve('./dal')];
const dalFunc = require('./dal');
const dal = dalFunc('phones/phones.json');
function getPhones(callback) {
dal.readAll(function (err, phonesData) {
if (err) {
callback(err);
} else {
callback(null, phonesData);
}
})
}
function getPhone(id, callback) {
dal.readOne(id, function (err, runnerData) {
if (err) {
callback(err);
} else {
callback(null, runnerData);
}
})
}
function createPhone(newPhoneData, callback) {
dal.saveOne(newPhoneData, function (err, data) {
if (err) {
callback(err);
} else {
callback(null, data);
}
})
}
function updatePhone(phone, callback) {
dal.updateOne(phone, function (err, data) {
if (err) {
callback(err);
} else {
callback(null, data);
}
})
}
function deletePhone(id, callback) {
dal.deleteOne(id, function (err, data) {
if (err) {
callback(err);
} else {
callback(null, data);
}
})
}
module.exports.getPhones = getPhones;
module.exports.getPhone = getPhone;
module.exports.createPhone = createPhone;
module.exports.updatePhone = updatePhone;
module.exports.deletePhone = deletePhone;