-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
36 lines (29 loc) · 993 Bytes
/
test.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
32
33
34
35
36
var Animal = require('./models/Animal.js');
var doggy = new Animal({ name: "Blacky", type: "Dog", color: "Black", breed: "Labrador" });
var kitty = new Animal({ name: "Lighty", type: "Cat", color: "White" });
// save a new dog into the database
doggy.save(function (err) {
if (err) console.log(err);
else console.log('Dog : ' + doggy.name + ' successfully saved.');
});
// find all other dogs in the database
doggy.findSimilarTypes(function (err, dogs) {
console.log(dogs);
});
// ask the dog to speak it's language
doggy.speak(function (err, text) {
console.log(text);
});
// save a new dog into the database
kitty.save(function (err) {
if (err) console.log(err);
else console.log('Cat : ' + kitty.name + ' successfully saved.');
});
// ask the cat to speak it's language
kitty.speak(function (err, text) {
console.log(text);
});
// find any animal by it's Id
Animal.findById("543adf311690a3107229d7ec", function (err, animal) {
console.log(animal);
});