|
| 1 | +function net_box_session() |
| 2 | + local net_box = require('net.box') |
| 3 | + local conn = net_box. connect( 'sampleuser:[email protected]:3301') |
| 4 | + conn:ping() |
| 5 | + |
| 6 | + conn.space.bands:insert { 1, 'Roxette', 1986 } |
| 7 | + conn.space.bands:insert { 2, 'Scorpions', 1965 } |
| 8 | + conn.space.bands:insert { 3, 'Ace of Base', 1987 } |
| 9 | + conn.space.bands:insert { 4, 'The Beatles', 1960 } |
| 10 | + --[[ |
| 11 | + --- |
| 12 | + ... |
| 13 | + ]] |
| 14 | + |
| 15 | + conn.space.bands:select(1) |
| 16 | + --[[ |
| 17 | + --- |
| 18 | + - - [1, 'Roxette', 1986] |
| 19 | + ... |
| 20 | + ]] |
| 21 | + |
| 22 | + conn.space.bands.index.band:select('The Beatles') |
| 23 | + --[[ |
| 24 | + --- |
| 25 | + - - [4, 'The Beatles', 1960] |
| 26 | + ... |
| 27 | + ]] |
| 28 | + |
| 29 | + conn.space.bands:update({ 2 }, { { '=', 2, 'Pink Floyd' } }) |
| 30 | + --[[ |
| 31 | + --- |
| 32 | + - [2, 'Pink Floyd', 1965] |
| 33 | + ... |
| 34 | + ]] |
| 35 | + |
| 36 | + conn.space.bands:upsert({ 5, 'The Rolling Stones', 1962 }, { { '=', 2, 'The Doors' } }) |
| 37 | + --[[ |
| 38 | + --- |
| 39 | + ... |
| 40 | + ]] |
| 41 | + |
| 42 | + conn.space.bands:replace { 1, 'Queen', 1970 } |
| 43 | + --[[ |
| 44 | + --- |
| 45 | + - [1, 'Queen', 1970] |
| 46 | + ... |
| 47 | + ]] |
| 48 | + |
| 49 | + conn.space.bands:delete(5) |
| 50 | + --[[ |
| 51 | + --- |
| 52 | + - [5, 'The Rolling Stones', 1962] |
| 53 | + ... |
| 54 | + ]] |
| 55 | + |
| 56 | + conn:call('get_bands_older_than', { 1966 }) |
| 57 | + -- --- |
| 58 | + -- - [[2, 'Pink Floyd', 1965], [4, 'The Beatles', 1960]] |
| 59 | + -- ... |
| 60 | + |
| 61 | + conn:close() |
| 62 | + --[[ |
| 63 | + --- |
| 64 | + ... |
| 65 | + ]] |
| 66 | +end |
0 commit comments