-
Notifications
You must be signed in to change notification settings - Fork 0
/
dbTest.js
41 lines (37 loc) · 957 Bytes
/
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
const db = require('./models');
// const addUserTweet = async () => {
// const user = await db.user.findOne();
// console.log(user);
// const [ tweet ] = await db.tweet.findOrCreate({
// where: {
// tweetId: '2',
// text: 'somethign special',
// author_id: '123'
// }
// });
// // res.locals.user
// await user.addTweet(tweet);
// const foundTweets = await user.getTweets();
// console.log(foundTweets);
// };
// addUserTweet();
const getAllUserTweets = async () => {
const user = await db.user.findAll({
where: {
id: 5
},
include: db.tweet
});
const arrWithIds = [];
user.forEach((element, i) => {
const allTweets = element.tweets;
allTweets.forEach((tweet, i) => {
// arrWithIds.push(tweet.dataValues.tweetId);
// const arr = [ tweet.dataValues.tweetId ];
const num = 1502797789176152067;
console.log(parseInt(tweet.dataValues.tweetId) === num);
});
});
};
// element.tweets[i]
getAllUserTweets();