-
Notifications
You must be signed in to change notification settings - Fork 12
/
install.js
87 lines (79 loc) · 4.79 KB
/
install.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
84
85
86
87
/*
Use this script at installation
*/
'use strict'
let mongoose = require('mongoose'),
pageModel = require('./app/models/page'),
postModel = require('./app/models/post'),
userModel = require('./app/models/user')
const ENV = require('./config/env')
mongoose.connect(ENV.db, (err) => {
if (err) {
console.error(err.stack)
} else {
userModel.find({}, (err, users) => {
if (!err) {
if (users.length === 0) {
userModel.create({
email: "[email protected]",
password: "21232f297a57a5a743894a0e4a801fc3",
isAdmin: true
}, (err, user) => {
if (!err) {
console.log("User admin created !")
} else {
console.log(err)
}
})
} else {
console.log("User(s) existing")
}
} else {
console.log(err)
}
})
pageModel.find({}, (err, pages) => {
if (!err) {
if (pages.length === 0) {
pageModel.create({
name: "home",
content: "{\"title\":\"<span class=\\\"ng-scope\\\">Build anything with code</span>\",\"subtitle\":\"<span class=\\\"ng-scope ite-italic\\\">Remember you are the code</span>\",\"concept1\":{\"title\":\"<span class=\\\"ng-scope\\\">Concept 1</span>\",\"content\":\"<span style=\\\"text-align: justify;\\\" class=\\\"ng-scope\\\">Lorem </span><span style=\\\"text-align: justify;\\\" class=\\\"ng-scope\\\">ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</span>\"},\"section1\":{\"title\":\"<span class=\\\"ng-scope\\\">Details</span>\",\"content\":\"<div style=\\\"text-align: justify;\\\" class=\\\"ng-scope\\\">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>\"},\"concept2\":{\"title\":\"<span class=\\\"ng-scope\\\">Concept 2</span>\",\"content\":\"<span style=\\\"text-align: justify;\\\" class=\\\"ng-scope\\\">Lorem </span><span style=\\\"text-align: justify;\\\" class=\\\"ng-scope\\\">ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</span>\"},\"concept3\":{\"title\":\"<span class=\\\"ng-scope\\\">Concept 3</span>\",\"content\":\"<span style=\\\"text-align: justify;\\\" class=\\\"ng-scope\\\">Lorem </span><span style=\\\"text-align: justify;\\\" class=\\\"ng-scope\\\">ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</span>\"}}"
}, (err, page) => {
if (!err) {
console.log("Page Home created !")
} else {
console.log(err)
}
})
} else {
console.log("Page(s) existing")
}
} else {
console.log(err)
}
})
postModel.find({}, (err, posts) => {
if (!err) {
if (posts.length === 0) {
postModel.create({
title: "Sample",
content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
}, (err, post) => {
if (!err) {
console.log("Post sample created !")
} else {
console.log(err)
}
mongoose.connection.close()
})
} else {
console.log("Post(s) existing")
mongoose.connection.close()
}
} else {
console.log(err)
mongoose.connection.close()
}
})
}
})