From 3f4dc96e97769a71f4b127617789311ed4bbb96e Mon Sep 17 00:00:00 2001 From: Tykayn Date: Thu, 7 Jul 2022 19:16:56 +0200 Subject: [PATCH] create db ok --- .gitignore | 2 +- mastodon_multi_accounts.db | Bin 20480 -> 20480 bytes routes/index.js | 69 +++++++++++++++++-------------------- 3 files changed, 32 insertions(+), 39 deletions(-) diff --git a/.gitignore b/.gitignore index b0c16e5..a1d95fc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ /.env -masto_posts.db +*.db node_modules \ No newline at end of file diff --git a/mastodon_multi_accounts.db b/mastodon_multi_accounts.db index 00fc4e764ad47300bef557eaa6c598535dd69711..91b295391b870399caad80d09526fad0e8901df6 100644 GIT binary patch delta 348 zcmZozz}T>Wae}lUI|Bm)D-bgSF%uB8Pt-9MWoOWfHsJ+{@L4nPS@ZSsi|~tV78FS4 zW#JEIw4HpLHz6i~iA`Kvn=!H^F)1gtxG*QPBsIP`wXifbFBzT7;vD4a7~-lB;^^e# zs(_|eBQG&GRR^e3v#EfY9b{yy_~eJY%8X2tS@~QNQqxn5xD?Ppa(-TMNl{{EUWr0M zesM{0d~tF{YD#HNYD#=THil}D=7OTk+{B_vh3wQyg~Za5{LH-MqSV~fypqXrd@}51 ziABj7iA9t5@`+Dgz{i2amq%iYv!^7Mq?TmnPU06?Bp@&`fSs2S7)GGb1BDz5Fo53h IFEUU702m`+D*ylh delta 457 zcmZozz}T>Wae}lU69WSSD-go~(?lI(Q6>hxXcJ!k9}FzK*BSVO`H%Bn=NH*5D3Hv{ z(qzTVKKV9pf>dUHUVLVX0tjU0l_(SxW#%RpRVrksR!%<0FFrY!pO3#JwW0*9078Jo zWs~#sN>YL9Apnbt$@}>^>JhR!Tu`N8DkZTbHNH4GBQ>QoCshH&E6L1Fg)7mtWnmK! z)MjMJ%u7kFC@##&1S(G~Ey)M-;|ubOON!yzQ{oNL1Xzn0*~MjL85`@(OA?cEQWFab z;(>M~!e}PvAXmo_SA`HqCm&Y@n5cpV(0*V@ggFK|dpHIu`1yw@_=WoTC { - getAllPosts(newdb); - }); + async function prepare() { + await db.query(sql` + create table posts_scheduled + ( + action_id integer + constraint posts_scheduled_pk + primary key autoincrement, + post_username varchar not null, + content varchar not null, + medias varchar, + datetime datetime + ); + + create unique index posts_scheduled_action_id_uindex + on posts_scheduled (action_id); + + insert into posts_scheduled + values (NULL, "modominem", "un message d'example", NULL); + + `); + console.log('requête de création faite') + } + const prepared = prepare(); } function getAllPosts(db) { - db.all(` - select * - from posts_scheduled p orderyby p.action_id desc`, "les posts", (err, rows) => { - if (rows) { - rows.forEach(row => { - console.log(row.post_username + "\t" + - row.content + "\t" + - row.medias); - }); - } else { - console.log('no rows') - } - - }); + db.query(sql`SELECT * FROM posts_scheduled;`).then( + (results) => + { + console.log(results) + }, + (err) => console.error(err), + ); } router.get('/init-db', function (req, res, next) {