Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. Lists = new Mongo.Collection('lists');
  2.  
  3. var Schema = {};
  4.  
  5. Schema.Lists = new SimpleSchema({
  6. name: {
  7. type: String
  8. },
  9. incompleteCount: {
  10. type: Number
  11. }
  12. });
  13.  
  14. Lists.attachSchema(Schema.Lists);
  15.  
  16. Todos = new Mongo.Collection('todos');
  17.  
  18. Schema.Todos = new SimpleSchema({
  19. listId: {
  20. type: Object
  21. },
  22. text: {
  23. type: String
  24. },
  25. createdAt: {
  26. type: Date
  27. }
  28. });
  29.  
  30. Todos.attachSchema(Schema.Todos);
  31.  
  32. var timestamp = (new Date()).getTime();
  33. _.each(data, function(list) {
  34. var list_id = Lists.insert({name: list.name,
  35. incompleteCount: list.items.length});
  36.  
  37. _.each(list.items, function(text) { //line 43
  38. Todos.insert({listId: list_id, //line 44
  39. text: text,
  40. createdAt: new Date(timestamp)});
  41. timestamp += 1; // ensure unique timestamp.
  42. });
  43. });
  44.  
  45. (STDERR) throw(ex);
  46. (STDERR) ^
  47. (STDERR) Error: List id must be an object
  48. (STDERR) at getErrorObject (meteor://💻app/packages/aldeed_collection2-core/lib/collection2.js:345:1)
  49. (STDERR) at [object Object].doValidate (meteor://💻app/packages/aldeed_collection2-core/lib/collection2.js:328:1)
  50. (STDERR) at [object Object].Mongo.Collection.(anonymous function) [as insert] (meteor://💻app/packages/aldeed_collection2-core/lib/collection2.js:83:1)
  51. (STDERR) at meteor://💻app/server/bootstrap.js:44:1
  52. (STDERR) at Array.forEach (native)
  53. (STDERR) at Function._.each._.forEach (meteor://💻app/packages/underscore/underscore.js:105:1)
  54. (STDERR) at meteor://💻app/server/bootstrap.js:43:1
  55. (STDERR) at Array.forEach (native)
  56. (STDERR) at Function._.each._.forEach (meteor://💻app/packages/underscore/underscore.js:105:1)
  57. (STDERR) at meteor://💻app/server/bootstrap.js:39:1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement