Loading
Florian Genaudet
This is a live streamed presentation. You will automatically follow the presenter and see the slide they're currently on.
Mongo <-> MiniMongo
Mongo côté serveur
Mini Mongo côté client qui permet de faire le CRUD
Mini-Databases
https://www.meteor.com/mini-databases
MACFGT:demo fgenaudet$ meteor list
autopublish 1.0.4 (For prototyping only) Publish the entire database to all clients
blaze-html-templates 1.0.1 Compile HTML templates into reactive UI with Meteor Blaze
ecmascript 0.1.5 Compiler plugin that supports ES2015+ in all .js files
es5-shim 4.1.13 Shims and polyfills to improve ECMAScript 5 support
insecure 1.0.4 (For prototyping only) Allow all database writes from the client
jquery 1.11.4 Manipulate the DOM using CSS selectors
meteor-base 1.0.1 Packages that every Meteor app needs
mobile-experience 1.0.1 Packages for a great mobile user experience
mongo 1.1.2 Adaptor for using MongoDB and Minimongo over DDP
session 1.1.1 Session variable
standard-minifiers 1.0.1 Standard minifiers used with Meteor apps by default.
tracker 1.0.9 Dependency tracker to allow reactive callbacks
Permet d'écrire dans Mongo depuis le client.
Toutes les collections sont publiées vers le client, avec toute les données des objets.
meteor remove insecure
meteor remove autopublish
Games.allow({
insert: function(userId, game) {
/* only allow posting if you are logged in */
return !! userId;
},
remove: function(userId, game) {
return !! userId && game.createdBy === userId;
},
update: function(userId, game) {
return !! userId && game.createdBy === userId;
}
});
Meteor.methods({
addTask: function (text) {
// Make sure the user is logged in before inserting a task
if (! Meteor.userId()) {
throw new Meteor.Error("not-authorized");
}
Tasks.insert({
text: text,
createdAt: new Date(),
owner: Meteor.userId(),
username: Meteor.user().username
});
},
deleteTask: function (taskId) {
Tasks.remove(taskId);
},
setChecked: function (taskId, setChecked) {
Tasks.update(taskId, { $set: { checked: setChecked} });
}
});
// server: publish the rooms collection, minus secret info.
Meteor.publish("rooms", function () {
return Rooms.find({}, {fields: {secretInfo: 0}});
});
// publish only the secret info field
Meteor.publish("adminSecretInfo", function () {
return Rooms.find({admin: this.userId}, {fields: {secretInfo: 1}});
});
Messages.deny({
update: function (userId, doc, fields, modifier) {
if (_.contains(fields, "createdAt") || _.contains(fields, "userId")) {
return true;
}
}
});