Ionic Cordova SQLite,如果不存在则插入数据,如果数据存在则替换旧数据(Ionic Cordova SQLite, insert data if not exists, if data exists replace the old data)
我正在用Ionic和Cordova SQLite开发一个应用程序。 如果sqlite中不存在数据,但是如果数据存在于sqlite中,则应用程序将数据插入到sqlite中。 然后,应用程序正在替换旧数据。 以下是我的代码。 但我无法将数据插入到sqlite数据库中。
创建数据库
db = window.openDatabase("chatChannel.db", "1", "Demo SQLite Test", "2000"); $cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS chat_channel(id interger primary key, channel_name text unique, last_text text)")
插入数据
var query = "INSERT INTO chat_channel (channel_name, last_text) VALUES(?,?) ON DUPLICATE KEY UPDATE (last_text) VALUES (?)"; $cordovaSQLite.execute(db, query, [channel, $scope.messageContent], [$scope.messageContent]);
如果sqlite数据库中不存在记录,我是否知道如何将数据插入cordova sqlite;如果数据库中存在数据,则更新数据。
I am developing an application with Ionic and Cordova SQLite. The application is inserting data into sqlite if data is not exists in sqlite but if data exists in sqlite. Then, application is replacing the old data. The following is my code. But I can't insert data into sqlite database.
Create Database
db = window.openDatabase("chatChannel.db", "1", "Demo SQLite Test", "2000"); $cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS chat_channel(id interger primary key, channel_name text unique, last_text text)")
Insert Data
var query = "INSERT INTO chat_channel (channel_name, last_text) VALUES(?,?) ON DUPLICATE KEY UPDATE (last_text) VALUES (?)"; $cordovaSQLite.execute(db, query, [channel, $scope.messageContent], [$scope.messageContent]);
May I know how to insert data into cordova sqlite if record not exist in sqlite database and update data if data is exists in database.
原文:https://stackoverflow.com/questions/39764826
最满意答案
做一个
sudo ntpdate -s time.nist.gov
Do a
sudo ntpdate -s time.nist.gov
相关问答
更多-
调用PutObject操作时的PermanentRedirect(PermanentRedirect when calling the PutObject operation)[2021-10-28]
错误说: 调用PutObject操作时发生错误( PermanentRedirect ):您尝试访问的存储区必须使用指定的端点进行寻址。 请将所有将来的请求发送到此端点 。 当您使用的Amazon S3存储桶位于创建Amazon S3客户端的其他区域时,通常会发生这种情况。 例如,存储桶位于us-west-2但客户端是为ap-southeast-2创建的。 您可以通过凭证文件指定区域,也可以在创建客户端对象时传递region_name 。 也可以在boto3.setup_default_session()定 ... -
这是个问题: delimiter=%2F&versions= 密钥和值应该是url-escaped(编码),但& between参数之间不应该转义为& ...它应该是& 。 您需要对每个键和值进行编码,而不是整个字符串进行排序和组合。 CanonicalQueryString 指定URI编码的查询字符串参数。 您可以单独对URI进行编码名称和值。 http://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth. ...
-
签名不匹配是一个非常常见的错误,并且难以找出确切的错误!! 我个人的建议是将请求与亚马逊暂存器请求进行比较。 这对我来说总是有帮助的。 并且params必须按字母顺序排列,以便匹配签名。 在此处尝试您的API请求: https : //mws.amazonservices.in/scratchpad/index.html并单击请求详细信息选项卡以查看完整请求URL,签名,md5哈希等。 Well, took me 2 days to realize that $string_to_sign = "GET\ ...
-
如果筛选器不匹配, describe_snapshots()不会返回None 。 此处的回复看起来像{'Snapshots': []} 。 您应该修改if以检查响应字典中Snapshots键下的列表长度。 if not len(all_snaps['Snapshots']): sys.exit(1) The describe_snapshots() does not return None when there is no match for the filters. The response h ...
-
我发现了我的错误:/它与卷曲无关,而是与我如何接近签名有关。 我一直在测试我的代码,方法是在流程的每个阶段测试输出,并将结果与亚马逊示例给出的结果进行比较。 这些都通过了,所以我确信我的代码是正确的。 但是,生成String to Sign需要Canonical请求的哈希值。 在我的代码中,我有一个生成规范请求并输出它的函数,但它也生成它的散列并将其存储在对象的公共变量中。 我的字符串签名生成函数在生成要签名的字符串时使用此变量。 现在我的测试代码称为规范请求,测试它的输出是有效的,然后调用字符串进行签名并 ...
-
如果您不使用任何AWS开发工具包发送http请求,则必须自己处理签名请求。 仅访问密钥和安全密钥是不够的。 请参考此文档 。 When you don't use any AWS SDK to send http request, you must handle sign request yourself. Only access key & security key is not enough. Please reference this document.
-
做一个 sudo ntpdate -s time.nist.gov Do a sudo ntpdate -s time.nist.gov
-
在加密操作期间发生错误.net框架4.5.1(error occurred during a cryptographic operation .net framework 4.5.1)[2023-02-13]
经过多次研究,这就是我解决问题的方法: 在这里生成机器密钥,并将机器密钥值添加到web.config。 此机器密钥将始终用于您托管您网站的webfarm上的任何服务器。 After many research this is how I solved the problem: Generate the machine key here and just add the machinekey values to web.config. This machine key will always be used ... -
弄清楚了。 在处理URL时,将unicode解析为纯文本。 我需要使用request.URL.Opaque。 更多信息: https : //stackoverflow.com/a/17322831/733860 这个问题与unicode有关。 在我的命令中有一个%2F(在我的原始问题中没有显示)Go转换为/应该保留为%2F(cURL正确地将其保留为%2F)。 将%2F更改为%252F解决了问题。 在创建新的HTTP请求时,Go似乎会将您的unicode解析回纯文本,因此如果您在提交给HTTP请求初始化程序 ...
-
由于我的debian机器上设置了错误的日期时间而发生错误。 我已经更改了时区并更正了日期时间,并且工作正常。 date --set 1998-11-02 date --set 21:08:00 自动设置时间 apt-get install ntp https://wiki.debian.org/DateTime#Set_the_time_automatically Laravel 5 Amazon AWS S3错误:客户端错误:403 RequestTimeTooSkewed The error wa ...