我有以下代码。
async function bulkInsert(db, collectionName, documents) {
try {
const cosmosResults = await db.collection(collectionName).insertMany(documents);
console.log(cosmosResults);
return cosmosResults
} catch (e) {
console.log(e)
}
}
Run Code Online (Sandbox Code Playgroud)
如果我使用大量文档来运行它,我会得到(并非意外)
{ MongoError: Message: {"Errors":["Request rate is large"]}
ActivityId: b3c83c38-0000-0000-0000-000000000000,
Request URI: /apps/DocDbApp/services/DocDbServer24/partitions/a4cb4964-38c8-11e6-8106-8cdcd42c33be/replicas/1p/,
RequestStats: , SDK: Microsoft.Azure.Documents.Common/1.19.102.5
at G:\Node-8\NodeExample\node_modules\oracle-movie-ticket-demo\node_modules\mongodb-core\lib\connection\pool.js:596:61
at authenticateStragglers (G:\Node-8\NodeExample\node_modules\oracle-movie-ticket-demo\node_modules\mongodb-core\lib\connection\pool.js:514:16)
at Connection.messageHandler (G:\Node-8\NodeExample\node_modules\oracle-movie-ticket-demo\node_modules\mongodb-core\lib\connection\pool.js:550:5)
at emitMessageHandler (G:\Node-8\NodeExample\node_modules\oracle-movie-ticket-demo\node_modules\mongodb-core\lib\connection\connection.js:309:10)
at TLSSocket.<anonymous> (G:\Node-8\NodeExample\node_modules\oracle-movie-ticket-demo\node_modules\mongodb-core\lib\connection\connection.js:452:17)
at emitOne (events.js:116:13)
at TLSSocket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at TLSSocket.Readable.push (_stream_readable.js:208:10)
name: 'MongoError',
message: 'Message: {"Errors":["Request rate is large"]}\r\nActivityId: b3c83c38-0000-0000-0000-000000000000,
Request …Run Code Online (Sandbox Code Playgroud) 如果我有以下json文件
C:\PostgresStage>type test2.json
{"key":"Hello \"World\""}
Run Code Online (Sandbox Code Playgroud)
我尝试使用 COPY 命令将它加载到 json 或 text 列中我最终得到了无效的 JSON 因为复制似乎从文件中去除了转义字符,如下所示
postgres=# \d+ T1
Table "public.t1"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+------+-----------+----------+---------+----------+--------------+-------------
data | text | | | | extended | |
postgres=# delete from T1;
DELETE 1
postgres=# copy t1 from 'c:\PostgresStage\test2.json';
COPY 1
postgres=# select * from T1;
data
-------------------------
{"key":"Hello "World""}
(1 row)
postgres=# select data::jsonb from T1;
ERROR: invalid input syntax for …Run Code Online (Sandbox Code Playgroud)