在 thinky (rethinkdb) 中强制执行唯一性
Enforce uniqueness in thinky (rethinkdb)
在 thinky.io 文档中描述了以下模式以强制执行唯一性:
var Model = thinky.createModel("user",
name: type.string()
}, {
pk: "name"
});
其中名称 属性 已分配给主键。
这是打字错误吗?也就是说,它应该是:
var Model = thinky.createModel("user", {
name: type.string()
}, {
pk: "name"
});
对于熟悉 thinky 且以前使用过此模式的任何人,是否有类似的分配唯一性的方法,就像在 mongoose (mongodb) 中所做的那样:
const userSchema = new Schema({
name: { type: String, unique: true }
});
谢谢。
更新:
link 到文档
https://thinky.io/documentation/faq/
是的,肯定是打字错误,因为第一个示例无效。
在 thinky.io 文档中描述了以下模式以强制执行唯一性:
var Model = thinky.createModel("user",
name: type.string()
}, {
pk: "name"
});
其中名称 属性 已分配给主键。
这是打字错误吗?也就是说,它应该是:
var Model = thinky.createModel("user", {
name: type.string()
}, {
pk: "name"
});
对于熟悉 thinky 且以前使用过此模式的任何人,是否有类似的分配唯一性的方法,就像在 mongoose (mongodb) 中所做的那样:
const userSchema = new Schema({
name: { type: String, unique: true }
});
谢谢。
更新: link 到文档 https://thinky.io/documentation/faq/
是的,肯定是打字错误,因为第一个示例无效。