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

时间:2015-04-20 13:56:56

标签: meteor iron-router

我制作了一些自动表单代码

问题是

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

1 个答案:

答案 0 :(得分:1)

您的架构和插入方法不匹配。另外,做一个autovalue - > @_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
相关问题