gpt4 book ai didi

simple-schema - 无法在带有 angular2-meteor 的 Mongo.Collection 上找到 attachSchema 属性

转载 作者:行者123 更新时间:2023-12-05 08:56:27 24 4
gpt4 key购买 nike

这是我的问题:

我想使用 simple-schema 的强大功能来根据以下模式检查我的插入:

let UprocSchema = new SimpleSchema({
"name": { type : String, label: "Nom Uproc" },
"label": { type : String, label: "Libellé Uproc" },
"status": { type : String, label: "Status UPR" }
});

出于某种原因我忽略了,即使 SimpleSchema 看起来实例化得很好,我也不能在 Mongo.Collection 上使用 attachSchema 属性。

这是我的代码:

let repo_collection = new Mongo.Collection('repository');
export const Repository = new MongoObservable.Collection<Uproc>('repo_collection');
repo_collection.attachSchema( UprocSchema );

这是我的错误信息:

Property 'attachSchema' does not exist on type 'Collection<{}>'.

TypeError: repo_collection.attachSchema is not a function

最佳答案

attachSchema[collection2][1] 包的一部分。

Documentation状态:

Create one or more SimpleSchema instances and then use them to validate objects. By adding the aldeed:collection2 package to your app, you can attach them to collections to get automatic validation of your insert and update operations.

关于simple-schema - 无法在带有 angular2-meteor 的 Mongo.Collection 上找到 attachSchema 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40616694/

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