simple-schema

Seperate publish function our of schema and into server/publications.js

早过忘川 提交于 2019-12-12 01:43:54
问题 I'm trying to update my application to utilise Meteors suggested file structure and I'm having trouble separating the publish function from the schema file. the file structure I'm trying to use is imports/ api/ profile/ server/ publications.js Profile.js When I combine the publish function into the Profile.js schema file the publish function works and the data flows through to the client however when I separate them I'm unable to get it to publish. Can someone please show me how to separate

Changing Meteor schema validations at different stages of object lifecycle?

筅森魡賤 提交于 2019-12-12 01:13:24
问题 I'm making a complex form for a shopping cart and I want to validate different parts of my order object at different stages of the order process. OrderSchema = new SimpleSchema({ itemsOrdered: { type: [Object], optional: false, }, totalPrice: { type: Number, optional: false, }, status: { type: String, optional: false }, termsAgreed: { type: Boolean, optional: false }, customerAddress: { type: Object, optional: false }, stripePaymentInfo: { type: Object, optional: true, blackbox: true }, });

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

Validate date values in Meteor AutoForm SimpleSchema

寵の児 提交于 2019-12-10 20:57:08
问题 I have the following Schema: Dates.attachSchema(new SimpleSchema({ description: { type: String, label: "Description", max: 50 }, start: { type: Date, autoform: { afFieldInput: { type: "bootstrap-datepicker" } } }, end: { type: Date, autoform: { afFieldInput: { type: "bootstrap-datepicker" } } } })); How can I validate that the end date is not before start ? I am using MomentJS to handle date types, however my main problem is how I can access other attributes in the custom function. For

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

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,