sample.cto文件
namespace org.example.basic
asset Supplier identified by suppliername
{
o String suppliername
}
asset product identified by productname{
o String productname
-->Supplier supplier
o Integer amount
}
transaction SampleTransaction {
-->product productasset
o String productname
o String supplier
o Integer amount
}
logic.js文件
/ ** *示例交易处理器功能。 * @param {org.example.basic.SampleTransaction} tx示例事务实例。 * @交易 * /
async function createPost(tx) {
var factory = getFactory();
return getAssetRegistry("org.example.basic.product")
.then(function(postAssetRegistry) {
var productname=tx.productname
newPost = factory.newResource("org.example.basic", "product", productname);
newPost.productname = tx.productname;
newPost.supplier = tx.supplier;
newPost.amount=tx.amount;
return postAssetRegistry.add(newPost);
})
}
答案 0 :(得分:0)
在模型文件的事务定义中,您指定一个字符串,但是在脚本CREATE SCHEMA Sprockets AUTHORIZATION Annik
CREATE TABLE NineProngs (source int, cost int, partnumber int)
GRANT SELECT ON SCHEMA::Sprockets TO Mandar
DENY SELECT ON SCHEMA::Sprockets TO Prasanna;
GO
的这一行中,Composer将newPost.supplier属性强制为一种关系,因此其值应类似于newPost.supplier = tx.supplier;