gpt4 book ai didi

javascript - 简单模式/AutoForm 集合插入中的用户特定字段 [Meteor]

转载 作者:可可西里 更新时间:2023-11-01 10:29:46 25 4
gpt4 key购买 nike

我使用简单模式和快速表单允许用户将文档保存到我的集合中,但我想添加 Meteor.userId()Meteor.user().username 字段最终只返回特定于当前用户的数据。由于 quickForms 不显示其 insert() 方法,我不确定在何处添加字段。

下面是我用来允许用户将 Speakers 持久保存到集合中的架构。

    Speakers = new Meteor.Collection('speakers');

Speakers.attachSchema(new SimpleSchema({
first: {
type: String,
label: "first name",
max: 200
},

last: {
type: String,
label: "last name",
max: 200
},

date: {
type: Date,
label: 'date',
optional: true
}
}));

最佳答案

我不确定我是否理解正确,但为什么不

Speakers.attachSchema(new SimpleSchema({
first: {
type: String,
label: "first name",
max: 200
},

last: {
type: String,
label: "last name",
max: 200
},

date: {
type: Date,
label: 'date',
optional: true
},
userId: {
type: String
}
}));

使用autovalue如果您想根据插入记录的用户自动填充

要使用 quickForm 而不显示 userId 字段,您可以执行以下操作

{{> quickForm collection="Speakers" id="speakerForm" type="insert" omitFields="userId"}}

关于javascript - 简单模式/AutoForm 集合插入中的用户特定字段 [Meteor],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28310145/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com