181 lines
3.4 KiB
JavaScript
181 lines
3.4 KiB
JavaScript
import { Meteor } from 'meteor/meteor';
|
|
import { PoblesCollection } from '/imports/api/pobles.js';
|
|
|
|
async function insertPoble({ nomPoble, cp, comarca }) {
|
|
await PoblesCollection.insertAsync({ nomPoble, cp, comarca, createdAt: new Date() });
|
|
}
|
|
|
|
Meteor.startup(async () => {
|
|
// If the Pobles collection is empty, add some data.
|
|
if (await PoblesCollection.find().countAsync() === 0) {
|
|
await insertPoble({
|
|
nomPoble: "Alaquàs",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
|
|
await insertPoble({
|
|
nomPoble: "Albal",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
await insertPoble({
|
|
nomPoble: "Aldaia",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
await insertPoble({
|
|
nomPoble: "Alfafar",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
await insertPoble({
|
|
nomPoble: "Algemesí",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
await insertPoble({
|
|
nomPoble: "Alginet",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
await insertPoble({
|
|
nomPoble: "Alcàsser",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
await insertPoble({
|
|
nomPoble: "Benetússer",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
await insertPoble({
|
|
nomPoble: "Beniparrell",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
await insertPoble({
|
|
nomPoble: "Carlet",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
await insertPoble({
|
|
nomPoble: "Catarroja",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
await insertPoble({
|
|
nomPoble: "Dosaigües",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
|
|
await insertPoble({
|
|
nomPoble: "Godelleta",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
await insertPoble({
|
|
nomPoble: "Guadassuar",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
await insertPoble({
|
|
nomPoble: "Iàtova",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
await insertPoble({
|
|
nomPoble: "L'Alcúdia",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
await insertPoble({
|
|
nomPoble: "Llocnou de la Corona",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
await insertPoble({
|
|
nomPoble: "Massanassa",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
|
|
|
|
|
|
await insertPoble({
|
|
nomPoble: "Paiporta",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
await insertPoble({
|
|
nomPoble: "Parke Alkosa",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
await insertPoble({
|
|
nomPoble: "Picanya",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
await insertPoble({
|
|
nomPoble: "Sedaví",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
await insertPoble({
|
|
nomPoble: "Setaigües",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
await insertPoble({
|
|
nomPoble: "Utiel",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
|
|
await insertPoble({
|
|
nomPoble: "València-Castellar Oliveral",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
await insertPoble({
|
|
nomPoble: "València-Forn d'Alcedo",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
await insertPoble({
|
|
nomPoble: "València-La Torre",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
await insertPoble({
|
|
nomPoble: "Xest",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
await insertPoble({
|
|
nomPoble: "Xiva",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
await insertPoble({
|
|
nomPoble: "Llombai",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
await insertPoble({
|
|
nomPoble: "Tremolar",
|
|
cp: "",
|
|
comarca: ""
|
|
});
|
|
|
|
}
|
|
|
|
// We publish the entire Pobles collection to all clients.
|
|
// In order to be fetched in real-time to the clients
|
|
Meteor.publish("pobles", function () {
|
|
return PoblesCollection.find();
|
|
});
|
|
});
|