update,
This commit is contained in:
22
COMP3322A-Lab-6-Nodejs-WebService-Pug/gen_db.js
Normal file
22
COMP3322A-Lab-6-Nodejs-WebService-Pug/gen_db.js
Normal file
@@ -0,0 +1,22 @@
|
||||
var MongoClient = require("mongodb").MongoClient;
|
||||
|
||||
var topic_name = ["www", "html", "css", "javascript", "nodejs", "jquery", "louiscklaw1", "louiscklaw2", "louiscklaw3"];
|
||||
var topic_status = ["no", "no", "no", "no", "no", "no", "no", "no", "no"];
|
||||
var topic_hour = [2, 4, 4, 6, 10, 6, 1, 2, 3];
|
||||
|
||||
MongoClient.connect("mongodb://mongo:27017/", function (err, result) {
|
||||
if (!err) {
|
||||
console.log("We are connected");
|
||||
var db = result.db("lab6-db");
|
||||
|
||||
db.collection("topicList").remove({});
|
||||
|
||||
for (let i = 0; i < topic_name.length; i++) {
|
||||
db.collection("topicList").insert({
|
||||
name: topic_name[i],
|
||||
hour: topic_hour[i],
|
||||
status: topic_status[i],
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user