-
Notifications
You must be signed in to change notification settings - Fork 135
Expand file tree
/
Copy pathapp-people.js
More file actions
80 lines (64 loc) · 1.6 KB
/
Copy pathapp-people.js
File metadata and controls
80 lines (64 loc) · 1.6 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// jshint node: true
'use strict';
const mongoose = require('mongoose');
mongoose.Promise = global.Promise;
mongoose.connect('mongodb://localhost/mongoose-crud');
const db = mongoose.connection;
const Person = require('./models/person.js');
const done = function() {
db.close();
};
const create = function(givenName, surname, dob, gender, height, weight) {
/* Add Code Here */
};
const index = function() {
/* Add Code Here */
};
const show = function(id) {
/* Add Code Here */
};
const update = function(id, field, value) {
/* Add Code Here */
};
const destroy = function(id) {
/* Add Code Here */
};
db.once('open', function() {
let command = process.argv[2];
// Using more than once, avoiding jshint complaints
let field;
let id;
switch (command) {
case 'create':
let givenName = process.argv[3];
let surname = process.argv[4];
let dob = process.argv[5];
let gender = process.argv[6];
let height = process.argv[7];
let weight = process.argv[8];
if (true || givenName) {
create(givenName, surname, dob, gender, height, weight);
} else {
console.log('usage c <given_name> <surname> <date of birth> [gender], <height>, <weight>');
done();
}
break;
case `show`:
id = process.argv[3];
show(id);
break;
case 'update':
id = process.argv[3];
field = process.argv[4];
let value = process.argv[5];
update(id, field, value);
break;
case 'destroy':
id = process.argv[3];
destroy(id);
break;
default:
index();
break;
}
});