Fix(skel-svelte): adjusted skel startup and added links.js

This commit is contained in:
Gabriel Grubba
2022-07-29 10:34:59 -03:00
parent 7abe8df134
commit fcb657c335
2 changed files with 31 additions and 2 deletions

View File

@@ -0,0 +1,3 @@
import { Mongo } from 'meteor/mongo';
export const LinksCollection = new Mongo.Collection('links');

View File

@@ -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',
});
}
});