| 1 |
create schema xtest; |
| 2 |
|
| 3 |
command ok |
| 4 |
RUN use xtest |
| 5 |
|
| 6 |
0 rows affected |
| 7 |
RUN insert into mycoll (doc) values ('{"_id": "1", "name": "Robb"}') |
| 8 |
|
| 9 |
1 rows affected |
| 10 |
RUN insert into mycoll (doc) values ('{"_id": "2", "name": "Bran"}') |
| 11 |
|
| 12 |
1 rows affected |
| 13 |
RUN insert into mycoll (doc) values ('{"_id": "3", "name": "Arya"}') |
| 14 |
|
| 15 |
1 rows affected |
| 16 |
RUN insert into mycoll (doc) values ('{"_id": "4", "name": "Sansa"}') |
| 17 |
|
| 18 |
1 rows affected |
| 19 |
RUN create table mytable (id int primary key, name varchar(40), price decimal(5,2), info json) |
| 20 |
|
| 21 |
0 rows affected |
| 22 |
RUN insert into mytable values (1, 'banana', 1.20, '{"color": "yellow"}') |
| 23 |
|
| 24 |
1 rows affected |
| 25 |
RUN insert into mytable values (2, 'apple', 0.25, '{"color":"red"}') |
| 26 |
|
| 27 |
1 rows affected |
| 28 |
RUN insert into mytable values (3, 'tomato', 1.80, '{"color":"red"}') |
| 29 |
|
| 30 |
1 rows affected |
| 31 |
RUN insert into mytable values (4, 'mango', 3.14, '{"color":"green"}') |
| 32 |
|
| 33 |
1 rows affected |
| 34 |
RUN insert into mytable values (5, 'orange', 0.90, '{"color":"orange"}') |
| 35 |
|
| 36 |
1 rows affected |
| 37 |
RUN SELECT * FROM xtest.mytable ORDER BY price |
| 38 |
id name price info |
| 39 |
2 apple 0.25 {"color": "red"} |
| 40 |
5 orange 0.90 {"color": "orange"} |
| 41 |
1 banana 1.20 {"color": "yellow"} |
| 42 |
3 tomato 1.80 {"color": "red"} |
| 43 |
4 mango 3.14 {"color": "green"} |
| 44 |
0 rows affected |
| 45 |
send Mysqlx.Crud.Delete { |
| 46 |
collection { |
| 47 |
name: "mytable" |
| 48 |
schema: "xtest" |
| 49 |
} |
| 50 |
data_model: TABLE |
| 51 |
limit { |
| 52 |
row_count: 2 |
| 53 |
} |
| 54 |
order { |
| 55 |
expr { |
| 56 |
type: IDENT |
| 57 |
identifier { |
| 58 |
name: "price" |
| 59 |
} |
| 60 |
} |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
2 rows affected |
| 66 |
RUN SELECT * FROM xtest.mytable |
| 67 |
id name price info |
| 68 |
1 banana 1.20 {"color": "yellow"} |
| 69 |
3 tomato 1.80 {"color": "red"} |
| 70 |
4 mango 3.14 {"color": "green"} |
| 71 |
0 rows affected |
| 72 |
RUN SELECT doc FROM xtest.mycoll ORDER BY JSON_UNQUOTE(JSON_EXTRACT(doc,'$.name')) |
| 73 |
doc |
| 74 |
{"_id": "3", "name": "Arya"} |
| 75 |
{"_id": "2", "name": "Bran"} |
| 76 |
{"_id": "1", "name": "Robb"} |
| 77 |
{"_id": "4", "name": "Sansa"} |
| 78 |
0 rows affected |
| 79 |
send Mysqlx.Crud.Delete { |
| 80 |
collection { |
| 81 |
name: "mycoll" |
| 82 |
schema: "xtest" |
| 83 |
} |
| 84 |
data_model: DOCUMENT |
| 85 |
limit { |
| 86 |
row_count: 2 |
| 87 |
} |
| 88 |
order { |
| 89 |
expr { |
| 90 |
type: IDENT |
| 91 |
identifier { |
| 92 |
document_path { |
| 93 |
type: MEMBER |
| 94 |
value: "name" |
| 95 |
} |
| 96 |
} |
| 97 |
} |
| 98 |
} |
| 99 |
} |
| 100 |
|
| 101 |
|
| 102 |
2 rows affected |
| 103 |
RUN SELECT doc FROM xtest.mycoll ORDER BY JSON_UNQUOTE(JSON_EXTRACT(doc,'$.name')) |
| 104 |
doc |
| 105 |
{"_id": "1", "name": "Robb"} |
| 106 |
{"_id": "4", "name": "Sansa"} |
| 107 |
0 rows affected |
| 108 |
Mysqlx.Ok { |
| 109 |
msg: "bye!" |
| 110 |
} |
| 111 |
ok |