Skip to content
Browse files

Changes necessary to use ObjectIDs with todos example

  • Loading branch information...
1 parent aad4b37 commit 4c65071c42970d1ef20a39dc76b3b84d2799de1c @glasser glasser committed Mar 21, 2013
Showing with 7 additions and 6 deletions.
  1. +5 −4 examples/todos/client/todos.js
  2. +2 −2 examples/todos/server/publish.js
View
9 examples/todos/client/todos.js
@@ -1,8 +1,8 @@
// Client-side JavaScript, bundled and sent to client.
// Define Minimongo collections to match server/publish.js.
-Lists = new Meteor.Collection("lists");
-Todos = new Meteor.Collection("todos");
+Lists = new Meteor.Collection("lists", {idGeneration: 'MONGO'});
+Todos = new Meteor.Collection("todos", {idGeneration: 'MONGO'});
// ID of currently selected list
Session.setDefault('list_id', null);
@@ -306,13 +306,14 @@ var TodosRouter = Backbone.Router.extend({
},
main: function (list_id) {
var oldList = Session.get("list_id");
- if (oldList !== list_id) {
+ list_id = list_id && new Meteor.Collection.ObjectID(list_id);
+ if (!EJSON.equals(oldList, list_id)) {
Session.set("list_id", list_id);
Session.set("tag_filter", null);
}
},
setList: function (list_id) {
- this.navigate(list_id, true);
+ this.navigate(list_id.toHexString(), true);
}
});
View
4 examples/todos/server/publish.js
@@ -1,5 +1,5 @@
// Lists -- {name: String}
-Lists = new Meteor.Collection("lists");
+Lists = new Meteor.Collection("lists", {idGeneration: 'MONGO'});
// Publish complete set of lists to all clients.
Meteor.publish('lists', function () {
@@ -12,7 +12,7 @@ Meteor.publish('lists', function () {
// tags: [String, ...],
// list_id: String,
// timestamp: Number}
-Todos = new Meteor.Collection("todos");
+Todos = new Meteor.Collection("todos", {idGeneration: 'MONGO'});
// Publish all items for requested list_id.
Meteor.publish('todos', function (list_id) {

0 comments on commit 4c65071

Please sign in to comment.
Something went wrong with that request. Please try again.