Chapter 7: initial samples

This commit is contained in:
Beth Griggs
2020-05-16 14:33:26 +01:00
parent bcf782f7dc
commit adb2130b38
140 changed files with 1777 additions and 1960 deletions
+23
View File
@@ -0,0 +1,23 @@
const mongoose = require('mongoose');
const URI = 'mongodb://localhost:27017/customers'
mongoose.connect(URI, {
useNewUrlParser: true,
useUnifiedTopology: true
})
const Customer = mongoose.model('Customer', {
forename: String,
surname: String
})
const customer_1 = new Customer({
forename: 'Beth',
surname: 'Griggs'
})
customer_1.save().then((doc) => {
console.log('Added new customer', doc.forename, doc.surname)
})