From fcb657c33562f4b2956a4f16eaf620f85eee0131 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com> Date: Fri, 29 Jul 2022 10:34:59 -0300 Subject: [PATCH] Fix(skel-svelte): adjusted skel startup and added links.js --- .../skel-svelte/imports/api/links.js | 3 ++ .../static-assets/skel-svelte/server/main.js | 30 +++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 tools/static-assets/skel-svelte/imports/api/links.js diff --git a/tools/static-assets/skel-svelte/imports/api/links.js b/tools/static-assets/skel-svelte/imports/api/links.js new file mode 100644 index 0000000000..050c508eae --- /dev/null +++ b/tools/static-assets/skel-svelte/imports/api/links.js @@ -0,0 +1,3 @@ +import { Mongo } from 'meteor/mongo'; + +export const LinksCollection = new Mongo.Collection('links'); diff --git a/tools/static-assets/skel-svelte/server/main.js b/tools/static-assets/skel-svelte/server/main.js index 31a9e0e2d6..9592a59154 100644 --- a/tools/static-assets/skel-svelte/server/main.js +++ b/tools/static-assets/skel-svelte/server/main.js @@ -1,5 +1,31 @@ import { Meteor } from 'meteor/meteor'; +import { LinksCollection } from '/imports/api/links'; -Meteor.startup(() => { - // code to run on server at startup +async function insertLink({ title, url }) { + await LinksCollection.insertAsync({ title, url, createdAt: new Date() }); +} + +Meteor.startup(async () => { + // If the Links collection is empty, add some data. + if (LinksCollection.find().count() === 0) { + await insertLink({ + title: 'Do the Tutorial', + url: 'https://svelte-tutorial.meteor.com/', + }); + + await insertLink({ + title: 'Follow the Guide', + url: 'https://guide.meteor.com', + }); + + await insertLink({ + title: 'Read the Docs', + url: 'https://docs.meteor.com', + }); + + await insertLink({ + title: 'Discussions', + url: 'https://forums.meteor.com', + }); + } });