-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseeder.js
84 lines (78 loc) · 2.43 KB
/
seeder.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
const mongoose = require("mongoose");
const mongodbHost = process.env.MONGODB_HOST || "localhost:27017";
const database = process.env.MONGODB_DATABASE || "nodeapi";
mongoose.connect(`mongodb://${mongodbHost}/${database}`, {
useNewUrlParser: true,
useUnifiedTopology: true
});
require("./src/models/Product");
const Product = mongoose.model('Product');
const products = [
{
title: "ReactJS",
description: "A declarative, efficient, and flexible JavaScript library for building user interfaces.",
url: "https://github.com/facebook/react"
},
{
title: "React Native",
description: "A framework for building native apps with React.",
url: "https://github.com/facebook/react-native"
},
{
title: "GraphQL",
description: "GraphQL is a query language and execution engine tied to any backend service.",
url: "https://github.com/facebook/graphql"
},
{
title: "Docosauros",
description: "Easy to maintain open source documentation websites.",
url: "https://github.com/facebook/docosauros"
},
{
title: "Nuclide",
description: "An open IDE for web and native mobile development, built on top of Atom",
url: "https://github.com/facebook/nuclide"
},
{
title: "create-react-app",
description: "Create React apps with no build configuration.",
url: "https://github.com/facebook/create-react-app"
},
{
title: "Metro",
description: "The JavaScript bundler for React Native.",
url: "https://github.com/facebook/metro"
},
{
title: "Relay",
description: "Relay is a JavaScript framework for building data-driven React applications.",
url: "https://github.com/facebook/relay"
},
{
title: "Flow",
description: "Adds static typing to JavaScript to improve developer productivity and code quality.",
url: "https://github.com/facebook/flow"
},
{
title: "Flipper",
description: "A desktop debugging platform for mobile developers.",
url: "https://github.com/facebook/flipper"
},
{
title: "Jest",
description: "Delightful JavaScript Testing.",
url: "https://github.com/facebook/jest"
},
{
title: "Watchman",
description: "Watches files and records, or triggers actions, when they change.",
url: "https://github.com/facebook/watchman"
},
]
products.forEach(async (item, index, array) => {
let product = new Product(item);
await product.save();
if ((index + 1) === array.length){
mongoose.disconnect();
}
});