From 1628971d5d98cd5873d333115a86d276bfa48f63 Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Wed, 8 Nov 2023 17:28:50 -0500 Subject: new blog post --- put_in_db.js | 61 +++++++++++++++++++++++++++++++----------------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/put_in_db.js b/put_in_db.js index a1de3ef..a9906a3 100644 --- a/put_in_db.js +++ b/put_in_db.js @@ -5,33 +5,36 @@ const fs = require("fs"); const path = require("path"); // db = connect("http://mongo:mongo@127.0.0.1:27117"); -blog_entry_1 = { - title: "Turning C structs into Lua tables", - slug: "c_struct_lua_table", - body: fs.readFileSync(path.join(__dirname) + "/mds/cstruct2luatable.md"), - teaser: "Turning C structures into Lua tables", - keywords: "c,lua", - lastUpdatedAt: Date.now(), -}; +blogs = [ + { + title: "Turning C structs into Lua tables", + slug: "c_struct_lua_table", + body: fs.readFileSync(path.join(__dirname) + "/mds/cstruct2luatable.md"), + teaser: "Turning C structures into Lua tables", + keywords: "c,lua", + lastUpdatedAt: Date.now(), + }, + { + title: "Lazy Makefiles", + slug: "lazy_makefile", + body: fs.readFileSync(path.join(__dirname) + "/mds/lazymakefiles.md"), + teaser: "Lazy Makefiles", + keywords: "makefile,c,c++", + lastUpdatedAt: Date.now(), + }, + { + title: "One Chat Client For Everything", + slug: "one_chat_client_for_everything", + body: fs.readFileSync( + path.join(__dirname) + "/mds/oneclientforeverything.md" + ), + teaser: "One Chat Client For Everything", + keywords: "irc,matrix,mattermost,matterbridge,bitlbee,irssi", + lastUpdatedAt: Date.now(), + }, +]; -blog_entry_2 = { - title: "Lazy Makefiles", - slug: "lazy_makefile", - body: fs.readFileSync(path.join(__dirname) + "/mds/lazymakefiles.md"), - teaser: "Lazy Makefiles", - keywords: "makefile,c,c++", - lastUpdatedAt: Date.now(), -}; - -blog_entry_3 = { - title: "One Chat Client For Everything", - slug: "one_chat_client_for_everything", - body: fs.readFileSync( - path.join(__dirname) + "/mds/oneclientforeverything.md" - ), - teaser: "One Chat Client For Everything", - keywords: "irc,matrix,mattermost,matterbridge,bitlbee,irssi", - lastUpdatedAt: Date.now(), -}; - -db.blogposts.insertMany([blog_entry_1, blog_entry_2, blog_entry_3]); +// db.blogposts.insertMany([blog_entry_1, blog_entry_2, blog_entry_3]); +db.blogposts.updateMany(blogs, { + upsert: true, +}); -- cgit v1.2.3