Last active
August 29, 2015 14:05
-
-
Save bvanasse/3d9ea919be3976070cd2 to your computer and use it in GitHub Desktop.
if the database is empty on server start, create some sample data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/meteor/meteor/blob/devel/examples/todos/server/bootstrap.js | |
// if the database is empty on server start, create some sample data. | |
Meteor.startup(function () { | |
if (Lists.find().count() === 0) { | |
var data = [ | |
{name: "Name", | |
contents: [ | |
["A", "B", "C"], | |
["One Language", "Simplicity", "Fun"] | |
] | |
} | |
]; | |
var timestamp = (new Date()).getTime(); | |
for (var i = 0; i < data.length; i++) { | |
var list_id = Lists.insert({name: data[i].name}); | |
for (var j = 0; j < data[i].contents.length; j++) { | |
var info = data[i].contents[j]; | |
Todos.insert({list_id: list_id, | |
text: info[0], | |
timestamp: timestamp, | |
tags: info.slice(1)}); | |
timestamp += 1; // ensure unique timestamp. | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment