javascript - fileLink is not allowed by schema -


i'm trying use simple schema in current meteor react project reason can't work.

this schema:

comments.schema = new simpleschema({    city: {      type: string,      label: 'the name of city.'    },      person: {      type: string,      label: 'the name of person.'    },    location: {      type: string,      label: 'the name of location.'    },    title: {      type: string,      label: 'the title of comment.'    },      content: {    type: string,    label: 'the content of comment.'    },      filelink: {    type: string,    regex: simpleschema.regex.url,    label: 'the url of file.'    },      createdby: {    type: string,    autovalue: function(){ return this.userid },    label: 'the id of user.'    }  });

and insert:

  createspark(event){      event.preventdefault();        const city = this.city.value;      const person = this.person.value;      const location = this.location.value;      const title = this.title.value;      const content = this.content.value;      const filelink = s3url;        insertcomment.call({        city, person, location, title, content, filelink        }, (error) => {          if (error) {                bert.alert(error.reason, 'danger');            } else {                target.value = '';                bert.alert('comment added!', 'success');            }        });      }

i'm saving value amazon in global variable called s3url. able console.log variable without problem when want write database getting "filelink not allowed schema" error.

anyone see doing wrong?

here comments.js file:

import faker 'faker';  import { mongo } 'meteor/mongo';  import { simpleschema } 'meteor/aldeed:simple-schema';  import { factory } 'meteor/dburles:factory';    export const comments = new mongo.collection('comments');    comments.allow({    insert: () => false,    update: () => false,    remove: () => false,  });    comments.deny({    insert: () => true,    update: () => true,    remove: () => true,  });    comments.schema = new simpleschema({    city: {      type: string,      label: 'the name of city.'    },      person: {      type: string,      label: 'the name of person.'    },    location: {      type: string,      label: 'the name of location.'    },    title: {      type: string,      label: 'the title of comment.'    },      content: {      type: string,      label: 'the content of comment.'    },      filelink: {      type: string,      regex: simpleschema.regex.url,      label: 'the url of file.'    },      createdby: {      type: string,      autovalue: function(){ return this.userid },      label: 'the id of user.'    }  });    comments.attachschema(comments.schema);

and methods.js file:

import { comments } './comments';  import { simpleschema } 'meteor/aldeed:simple-schema';  import { validatedmethod } 'meteor/mdg:validated-method';  import { ratelimit } '../../modules/rate-limit.js';    export const insertcomment = new validatedmethod({    name: 'comments.insert',    validate: new simpleschema({      city: { type: string },      person: { type: string, optional: true },      location: { type: string, optional: true},      title: { type: string },      content: { type: string },      filelink: { type: string, regex: simpleschema.regex.url },      createdby: { type: string, optional: true }    }).validator(),    run(comment) {      comments.insert(comment);    },  });    ratelimit({    methods: [      insertcomment,      ],    limit: 5,    timerange: 1000,  });

while working bit more on noticed things doing wrong. 1. didn't have right value simple schema set up. 2. problems have fact url has white spaces in it. can fix this? 3. current error getting is: "exception in delivering result of invoking 'comments.insert': referenceerror: target not defined."

while working bit more on noticed things doing wrong. 1. didn't have right value simple schema set up. 2. problems have fact url has white spaces in it. can fix this? 3. current error getting is: "exception in delivering result of invoking 'comments.insert': referenceerror: target not defined."

thanks @khang


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -