- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的文档中,当几个字段(post、price、desc)时,我想关闭批准标志。
对于这个问题,我首先关闭文档中所有记录的标志,然后仅打开唯一记录的标志。
function SProc() {
var collection = getContext().getCollection();
var collectionLink = collection.getSelfLink();
var response = getContext().getResponse();
var counter = 0;
var responseBody = {
updated: 0,
continuation: true,
error: "",
log: ""
};
// Validate input.
getFullListOfPosts();
// Recursively queries for a document by id w/ support for continuation tokens.
// Calls findDuplicates(document) as soon as the query returns a document.
function getFullListOfPosts(continuation) {
var query = {
query: "select * from root r ORDER BY r.created.epoch DESC"
};
var requestOptions = {
continuation: continuation
};
var isAccepted = collection.queryDocuments(collectionLink, query, requestOptions, proccessFullListOfPosts);
// If we hit execution bounds - throw an exception.
if (!isAccepted) {
responseBody.log += "Query not accepted";
response.setBody(responseBody);
throw new Error("The stored procedure timed out");
}
}
function proccessFullListOfPosts(err, documents, responseOptions) {
if (err) {
responseBody.error = err;
throw err;
}
if (documents.length > 0) {
responseBody.log += "Total records: " + documents.length;
var filtered = documents.filter(function(a) {
var key = a.posted_by + '|' + a.price + '|' + a.description + '|' + a.compare_price;
if (!this[key]) {
this[key] = true;
return true;
}
}, Object.create(null))
for (var i = 0; i < documents.length; i++) {
var allRec = documents[i]
disableAllrecords(allRec);
}
for (var i = 0; i < filtered.length; i++) {
var uniqRec = filtered[i]
enableUniqueRecords(uniqRec);
}
}
if (responseOptions.continuation) {
// Else if the query came back empty, but with a continuation token;
// repeat the query w/ the token.
getFullListOfPosts(responseOptions.continuation);
}
}
function disableAllrecords(element) {
element.is_approved = false;
element.likes = 56;
responseBody.log += " Will disable " + element.id + element.is_approved + element.likes;
var requestOptions = {
etag: element._etag
};
var isAccepted = collection.replaceDocument(element._self, element, requestOptions, function(err, updatedDocument, responseOptions) {
if (err) throw err;
counter++;
responseBody.log += " Disabled: " + element.id + " with approval:" + element.is_approved + " Likes:" + element.likes;
});
if (!isAccepted) {
throw new Error("The stored procedure timed out while disabling");
}
}
function enableUniqueRecords(x) {
x.is_approved = true;
x.likes = 65;
responseBody.log += " Will enable " + x.id + x.is_approved + x.likes;
var requestOptions = {
etag: x._etag
};
var isAccepted = collection.replaceDocument(x._self, x, requestOptions, function(err, updatedDocument, responseOptions) {
if (err) throw err;
counter++;
responseBody.log += " Enabled: " + x.id + " with approval:" + x.is_approved + " Likes:" + x.likes;
});
if (!isAccepted) {
throw new Error("The stored procedure timed out while enabling");
}
}
}
我在enableUniqueRecords() 中遇到错误。我无法理解我收到错误的原因和原因。
它说:
Error: {"Errors":["One of the specified pre-condition is not met"]}
最佳答案
Azhar,我想这里失败的是replaceDocument 调用。它一定会失败,因为不满足 _etag 前提条件,这应该是因为在该脚本(事务)启动后文档被其他人修改了。这种情况有可能吗?
要处理脚本内修改的文档,需要从客户端进行重试。您可以做的是(1)使用自定义消息抛出异常(如果您希望中止脚本事务)或(2)在请求正文中设置一些自定义标志(如果您希望到目前为止完成的脚本操作要提交),请识别这一点在客户端上并重试 ExecuteStoredProcedure 调用。
顺便说一句,对于存储过程来说,不需要 _etag 前置条件,因为如果在脚本启动后修改了文档,则由于快照隔离,更新文档会失败。
关于azure - 文档数据库 : Unable to update ALL records - Only 100 records are updated at a time,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38341719/
这个问题在这里已经有了答案: android studio adb Syntax error: ")" unexpected (4 个答案) 关闭 5 年前。 我确实将我的工作室更新到 Linux
当我打开 Android Studio 时,它会显示下面的对话框,我的应用程序无法以 Debug模式运行。 最佳答案 找到sdk->platform-tool文件夹,然后运行命令adb tcpip 5
我在 Fedora 33 机器上使用了 VSCode (1.52.1) 一段时间。 我正在使用 Docker 扩展 (v1.9.0) 但由于某种原因,在过去几天中,当我尝试将 VSCode 附加到 D
我正在尝试为我的任务加载一个名为“tr_model.h5”的预训练模型,但出现以下错误: Traceback (most recent call last): File "Trigger_Proje
我最近在 Google Play 中发布了一个 Android 应用程序,到目前为止一切看起来都很棒,但有一个异常(exception)(见下文),我有时会收到控制台崩溃的消息,它只发生在某些用户身上
单击警告时,我收到此消息。这是案件的截图。 错误写道, Unable to open 'warning.cpp': Unable to read file '/Users/dimen/code/C++
重新编译 php 后,当我使用 php cli 时出现以下错误: PHP Warning: PHP Startup: imap: Unable to initialize module Module
使用 git 1.6.4.2,当我尝试 git pull 时出现此错误: error: unable to resolve reference refs/remotes/origin/LT558-op
我是 Kotlin 的新手,我正在学习教程。运行我的应用程序会导致它在运行时崩溃。我在底部导航栏应用程序中有三个 fragment 和一个主要 Activity 。我的目标实际上只是成功运行该应用程序
我在 Windows 10 64 位上运行 Android Studio。我在 5 月 20 日早上升级到了最新的版本和 SDK,从那时起,我在打开 Android Studio 时收到上述错误。我还
因此,我创建了一个 GitHub 操作,该操作应该在发生推送时构建 docker 镜像并将其推送到 docker hub。所以这是我的 GitHub 操作:(第一次创建 GitHub 操作) name
当这些问题中的任何一个都没有帮助我时,这意味着我需要删除并重新安装 Android Studio。 这是错误: Error initializing ADB: Unable to create Deb
Iam running the latest OSX/Flutter/XCode Versions using flutter, android studio and firebase and
我最近重新安装了 ubuntu 20.04.3,在做了一些设置后,我现在在运行 apt update 时总是收到以下错误.我一定是不小心删除了某种缓存文件或目录,但我不知道如何诊断或解决这个问题。 任
今天,当我将更改推送到 Gitlab 中的代码存储库时,我才开始在 Gitlab 中收到此错误消息。 Gitlab fatal: unable to access '.......' SSL Cert
我正在使用 Protractor 和 Jasmine 。 我已经确定了 chrome 驱动程序版本:2.32.498550 (latest)与 Chrome 测试版不兼容 (Version 62.0.
我正在尝试使用 terraform (0.12.24) 和多个 Docker 提供程序(插件版本 2.7.0)执行简单部署。我使用下面的 Terraform 模板的目的是将两个不同的容器部署到两个不同
这个问题我看了很久,最后决定在这里提出来。我需要维护一些用 Delphi 2007 for .NET (ASP.NET 2.0) 编写的应用程序。通常,第一次运行应用程序(使用 IIS)时,我会收到经
如何修复 - 无法创建调试桥:无法启动 adb 服务器:无法检测 adb 版本,adb 输出:/home/dilip/Downloads/sdk/platform-tools/adb: 1:/home
通过命令提示符连接到 android 中的 Sqlite DB 时出现错误。 以下是我遵循的步骤: 我已经在 android 中通过 java 程序创建了 Sqlite 数据库。创建表并向其中插入数据
我是一名优秀的程序员,十分优秀!