Bug #96686 | Document not added in Collection if in while loop | ||
---|---|---|---|
Submitted: | 28 Aug 2019 19:29 | Modified: | 30 Aug 2019 17:14 |
Reporter: | Ralf Adams | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Document Store: MySQL Shell | Severity: | S2 (Serious) |
Version: | 8.0.17 | OS: | Windows |
Assigned to: | MySQL Verification Team | CPU Architecture: | Any |
Tags: | Add(), Collection, javascript, while |
[28 Aug 2019 19:29]
Ralf Adams
[30 Aug 2019 11:43]
MySQL Verification Team
Hi, You are missing .execute(); e.g. [arhimed@localhost msb_8_0_15]$ cat xx.js var mysqlx = require('mysqlx'); var mySession = mysqlx.getSession({host: 'localhost', port: 18015, user: 'msandbox', password: 'msandbox'}); var myDB = mySession.getSchema('test'); myDB.dropCollection('mycoll'); var coll = myDB.createCollection('mycoll'); coll.add({a:0}).execute(); var n=0; while (n < 9) { coll.add({a:2}).execute(); n=n+1; print(n); print("\n"); } coll.find(); mySession.close(); [arhimed@localhost msb_8_0_15]$ ./mysqlsh MySQL 127.0.0.1:18015+ ssl JS > \source xx.js Query OK, 1 item affected (0.0017 sec) 1 2 3 4 5 6 7 8 9 [ { "a": 0, "_id": "00005d69067b0000000000000014" }, { "a": 2, "_id": "00005d69067b0000000000000015" }, { "a": 2, "_id": "00005d69067b0000000000000016" }, { "a": 2, "_id": "00005d69067b0000000000000017" }, { "a": 2, "_id": "00005d69067b0000000000000018" }, { "a": 2, "_id": "00005d69067b0000000000000019" }, { "a": 2, "_id": "00005d69067b000000000000001a" }, { "a": 2, "_id": "00005d69067b000000000000001b" }, { "a": 2, "_id": "00005d69067b000000000000001c" }, { "a": 2, "_id": "00005d69067b000000000000001d" } ] 10 documents in set (0.0003 sec) MySQL 127.0.0.1:18015+ ssl JS >
[30 Aug 2019 11:44]
MySQL Verification Team
examples: https://dev.mysql.com/doc/x-devapi-userguide/en/collection-crud-function-overview.html
[30 Aug 2019 17:14]
Ralf Adams
Shame on me. Your're right, my mistake. Thanks.