Skip to content

Commit 5974d74

Browse files
authored
Don't use print in pairs example (#78)
In some cases when user explores how does `crud.pairs` work `print` doesn't work as expected (when connected to running instance console, message is printed to instance log, see tarantool/tarantool#1986) The better way is to collect data fetched by `pairs` to a table.
1 parent c5fc183 commit 5974d74

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,16 @@ User could pass use_tomap flag (false by default) to iterate over flat tuples or
322322
**Example:**
323323

324324
```lua
325+
local tuples = {}
325326
for _, tuple in crud.pairs('customers', {{'<=', 'age', 35}}, {use_tomap = false}) do
326-
print(json.encode(tuple)) -- {5, 1172, 'Jack', 35}
327+
-- {5, 1172, 'Jack', 35}
328+
table.insert(tuples, tuple)
327329
end
328330

331+
local objects = {}
329332
for _, object in crud.pairs('customers', {{'<=', 'age', 35}}, {use_tomap = true}) do
330-
print(json.encode(object)) -- {id = 5, name = 'Jack', bucket_id = 1172, age = 35}
333+
-- {id = 5, name = 'Jack', bucket_id = 1172, age = 35}
334+
table.insert(objects, object)
331335
end
332336
```
333337

0 commit comments

Comments
 (0)