var mongoose = require("mongoose");
mongoose.connect("mongodb://localhost/cat_app2");
//create the cat scheme
var catScheme = new mongoose.Schema({
name: String,
age: Number,
temperament: String
});
var Cat = mongoose.model("Cat", catScheme);
//thats how you create a new item (cat here)
var george = new Cat({
name: "George",
age: 11,
temperament: "Grouchy"
});
george.save(function (err, cat) { //callback run when save finished
if (err) {
console.log("SOMTHiNG WENT WRONG");
}
else {
console.log("WE JUST SAVE A CAT TO THE DB");
console.log(cat);
}
});