-
Notifications
You must be signed in to change notification settings - Fork 3
/
testDb.js
36 lines (24 loc) · 863 Bytes
/
testDb.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
const db = require('./models')
const referenceCrud = async ()=> {
try {
//CREATE (associating)
//have an instance of a user and an instance of a post(through creation or finding)
const newFavoriteMovie = await db.FavoriteMovie.findById('64535e757bf12c96fbbf3701')
const foundUser = await db.User.findOne({name : 'test 11'})
// const newFave = {
// title: 'LOTR',
// poster: 'www.x.com',
// rating: 'a'
// }
const push = foundUser.favorites.push(newFavoriteMovie.id)
await foundUser.save()
//addpost to users array of post id's
//add the user to the poster fields
//save the user
//save the post
//READING( querying with relationships)
}catch(err){
console.log(err)
}
}
referenceCrud()