我做了一些自动表单代码流星

I made some auto form code meteor

我做了一些自动表单代码

问题是

autoValue: ->
  @_id

不工作..

表格已制作但未提交

你们知道为什么吗?

Comments.insert
      createAt: new Date
      body: tmpl.find('textarea#com').value
      todoId: @_id

@Comments = new Mongo.Collection('comments')
Comments.attachSchema new SimpleSchema
  comments:
    type: String
    max: 100
    label: 'CommentsBody'
  commentsId:
    label: 'CommentsId'
    type: String
    autoValue: ->
      @_id
    autoform:
      omit: true

您的架构和插入方法不匹配。此外,执行自动值 -> @_id 是多余的,因为它将保存 _id 两次,一次在 _id 字段中,一次在 commentsId 中。 这是适用于您的方法的模式:

Comments.attachSchema new SimpleSchema
  body:
    type: String
    max: 100
    label: 'CommentsBody'
  createAt:
    type: Date
    autoValue: ->
      if @isInsert
          new Date()
    autoform:
      omit: true
  todoId:
    type: String