meteor-collection2

How to pass a default value for a field in 'insert' form?

拜拜、爱过 提交于 2019-12-10 17:09:06
问题 How to pass a default value for a field in 'insert' form? I'm using Meteor's packages: Autoform, Collections2, and Simple-Schema. My process is: A User selects some value in a list on a page, then The 'insert' from opens, and I want that one field to be initialized with the value the user chose on a previous step. Can't figure out how to pass a parameter withing URL (or any other way). The problem is how to initialize form with the value. Suppose I have an URL: http://localhost:3000/activity

No best common type exists among return expressions

旧时模样 提交于 2019-12-09 17:21:34
问题 When I use Collection2 in angular2-meteor project, these kinds of codes from demo always give me warning in the terminal: No best common type exists among return expressions. How can I improve the codes? Thanks { createdAt: { type: Date, autoValue: function() { if (this.isInsert) { return new Date(); } else if (this.isUpsert) { return {$setOnInsert: new Date()}; } else { this.unset(); } } } } 回答1: Since a type of Date is expected for EVERY return branch, you must return a Date type for every

No best common type exists among return expressions

半世苍凉 提交于 2019-12-04 03:32:20
When I use Collection2 in angular2-meteor project, these kinds of codes from demo always give me warning in the terminal: No best common type exists among return expressions. How can I improve the codes? Thanks { createdAt: { type: Date, autoValue: function() { if (this.isInsert) { return new Date(); } else if (this.isUpsert) { return {$setOnInsert: new Date()}; } else { this.unset(); } } } } Since a type of Date is expected for EVERY return branch, you must return a Date type for every if/else branch OR you can create a union that returns two different types. In either case, you can return

Updating array of objects in mongodb

故事扮演 提交于 2019-12-02 08:43:00
I'm trying to update an array of objects in my simple-schema. Currently, it removes everything in the database and leaves behind: "careerHistoryPositions": [] My simple-schema looks like: const ProfileCandidateSchema = new SimpleSchema({ userId: { type: String, regEx: SimpleSchema.RegEx.Id }, careerHistoryPositions: { type: Array, optional: true }, 'careerHistoryPositions.$': { type: Object, optional: true }, 'careerHistoryPositions.$.uniqueId': { type: String, optional: true }, 'careerHistoryPositions.$.company': { type: String, optional: true }, 'careerHistoryPositions.$.title': { type:

SimpleSchema is not a constructor

六眼飞鱼酱① 提交于 2019-12-02 04:39:35
My app constantly crashes with this error. TypeError: SimpleSchema is not a constructor at attendances.js (imports/api/attendances/attendances.js:44:27) . I've googled it and the StackOverflow solution doesn't work. I'm running simpl-schema and Collection2 Can anyone tell me whats wrong here? import { Mongo } from 'meteor/mongo'; import SimpleSchema from 'simpl-schema'; const Attendances = new Mongo.Collection('attendances'); Attendances.debug = true; Attendances.allow({ insert: () => true, update: () => true, remove: () => true, }); Attendances.deny({ insert: () => false, update: () => false,