更新时间:2022-03-24 07:15:49
您可以使用普通的JavaScript语法操作对象(添加/删除属性)。
You can manipulate the object (add / remove properties) using plain JavaScript syntax.
然后在服务器端使用DocumentDB JavaScript SDK创建文档
And then use the DocumentDB server-side JavaScript SDK to create the document.
以下是存储过程入门示例:
Here's an example Stored Procedure to get you started:
function transform(doc) {
var collection = getContext().getCollection();
var response = getContext().getResponse();
// Add new accountId and versions fields.
doc.accountId = "Test";
doc.versions = {
name: doc.name,
type: doc.type,
tags: [],
links: []
};
// Remove old name and type fields.
delete doc.name;
delete doc.type;
// Create the document.
collection.createDocument(collection.getSelfLink(), doc, function(err, result) {
if(err) throw err;
// Return the resulting document back as the response.
response.setBody(result);
});
}