-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdbTest.js
54 lines (48 loc) · 1.07 KB
/
dbTest.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
const mongoose = require('mongoose')
require('dotenv').config()
mongoose.connect(process.env.DATABASE_URL)
const Dog = require('./models/Dog')
const Application = require ('./models/Application')
function createDog(data) {
Dog.create(data)
.then(function(newDog) {
console.log(newDog)
return newDog.save()
})
.catch(function(err) {
console.log(err)
})
.finally(function() {
mongoose.connection.close()
})
}
function createApp(data) {
Application.create(data)
.then(function(newApp) {
console.log(newApp)
return newApp.save()
})
.catch(function(err) {
console.log(err)
})
.finally(function() {
mongoose.connection.close()
})
}
dogData = {
name: 'Indy',
gender: 'Male',
breed: 'Labrador',
weight: 80,
age: '7 years',
adoptionFee: 200
}
appData = {
name:'Nicole Prati',
phone: '467-208-5403',
emailAddress: 'nicoleprati@gmail.com',
numberOfPets: 1,
message: 'This doggo WILL be mine'
}
createApp(appData)
// createDog(dogData)