meteor-collection2

Meteor collection2 array with Strings and Object

余生颓废 提交于 2020-01-05 03:49:07
问题 i'm using Meteor with collection2 and I have an array that looks like this: productTypes = ["string1", "string2", "string3", {Other: "test"}] Essentially there will be anywhere from 0 to 7 strings in the array, and Other: 'Test' may or may not be present So i'm trying to make a schema that handles that case. Is there a way to tell it that there will be strings and an object within an array? I've tried const residentSchema = new SimpleSchema({ productTypes: {type: [String, Object], optional:

Select category not updating sub category

送分小仙女□ 提交于 2019-12-25 06:44:42
问题 This is suppose to look at the users category selection and then update the subcategory. The solution was recommended by someone else but I can't seem to get it to work. When I select the category, subcategory doesn't update. Can someone let me know what I'm missing. Path: category.js <template name="category"> {{#autoForm collection="Meteor.users" id="categoryForm" doc=currentUser type="update"}} {{> afQuickField name='profile.categories'}} {{/autoForm}} </template> Path: Schema.js var

Meteor Collections schema not allowing Google authentication

一笑奈何 提交于 2019-12-25 01:51:52
问题 I'm building a simple user account using MeteorJS. A user is only given the option to login/register using Google. If they are registering for the first time, users will be prompted to fill out their profile information after authenticating with their user account. I'm using Collections2 to manage the schema for a user account and attaching it to Meteor.users, which is seen here: var Schemas = {}; Schemas.UserProfile = new SimpleSchema({ firstName: { type: String, regEx: /^[a-zA-Z-]{2,25}$/,

Updating array of objects in mongodb

独自空忆成欢 提交于 2019-12-20 06:37:20
问题 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 },

SimpleSchema is not a constructor

此生再无相见时 提交于 2019-12-20 03:52:30
问题 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,

Meteor Mongo - upsert and $inc with aldeed simple schema - 'update failed'

这一生的挚爱 提交于 2019-12-12 18:36:06
问题 I have an image gallery with a forward and backward-button. on a click on either of the buttons i want to upsert an entry in the local database with the times the image has been viewed (so i can later see which image has been viewed the most). This works perfectly without the Schema: 'click .btn-forward, click .btn-backward' (event, template) { Local.Viewed.upsert({ imageId: this._id }, { $setOnInsert: { imageId: this._id, imageName: this.name }, $inc: { timesViewed: 1 } }); } }); The Schema:

how to set a default value to element in a collection of type [String]?

人盡茶涼 提交于 2019-12-12 17:24:48
问题 i have quickform once the submit button clicked, this method is fired submitPost: function (app) { check(app, { title: String, description: String, category: String, price: Number }); var knownId = Products.insert(app); Products.update({ _id: knownId }, { $set:{screenShots: scs, previewImage: pi, sourceCode: zip }}); } the submit button wasn't working when i didn't give "screenShots, previewImage, and sourceCode" a default values in a collection. Once i gave them a default value like it is

How to access and change a specific attribute in a collection?

不问归期 提交于 2019-12-12 05:29:26
问题 I have a collection called "Products". I want to access and change an attribute called "screenShots" inside the collection. This code didn't work with me screenshotsURLS: function(sshots) { check(sshots, [String]); Products.update({},{$set:{screenShots:sshots}}); console.log(sshots); } when i console.log the sshots, i can see that the array exists, but the update function isn't working how do i set the screenShots attribute inside the Product collection to whatever value passed in

Array of objects passes validation but doesn't update collection

折月煮酒 提交于 2019-12-12 04:15:43
问题 My update method is passing the simple-schema validation test however it isn't updating my collection. I'm updating an array of objects. Example: array var arrayTest = [ { company: 'sdsd', uniqueId: 1500431892902, title: '', description: '', startDateMonth: '', startDateYear: '', endDateMonth: '', endDateYear: '', isCurrent: false, isDisabled: false, } ]; Validate: Array new SimpleSchema({ company: { type: String, optional: true }, uniqueId: { type: Number, optional: true }, title: { type:

Autoform custom validation fails after multiple subsqeuent submits

那年仲夏 提交于 2019-12-11 06:48:53
问题 I'm using a custom validation on _id field as below. First I enter an ID and hit submit, it gets persisted in the DB. Next time, I reuse the same ID and try to submit, I get a validation error. I hit the submit button again, and I get a weird internal server error being thrown in the chrome logs. The validation error vanishes and feels as if the form is submitted successfully, but in reality it isn't. I'm not able to figure out why this happens on the second try onward. Typically, the