-
Notifications
You must be signed in to change notification settings - Fork 0
/
cat.js
54 lines (45 loc) · 850 Bytes
/
cat.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
var mongoose=require('mongoose')
mongoose.connect("mongodb://localhost/cat_app")
var catSchema=new mongoose.Schema({
name:String,
age:Number,
temperament:String
})
var Cat=mongoose.model("Cat",catSchema);
// var george=new Cat({
// name:"Ugur ",
// age:10,
// temperament:"Dizzy"
// })
// george.save(function(err,cat){
// if(err){
// console.log("Something went wrong")
// }
// else{
// console.log(cat)
// }
// })
//////qweklqekl;qwekl;
Cat.create({
name:"Missy",
age:12,
temperament:"Narcist"
},function(err,cat){
if(err){
console.log('Something went wrong')
}
else{
console.log(cat)
}
})
Cat.find({},function(err,cat){
if(err){
console.log("Something went wrong")
}
else{
console.log('All the Cats')
console.log(cat)
}
})
//add cats to the DB
// retrieve cats from DB