Created
November 14, 2020 12:31
-
-
Save ochaton/eea0cf0e5a3054e0a916699b2d24574f to your computer and use it in GitHub Desktop.
Tarantool ORM interface
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| box.orm = require 'orm' . configure { | |
| users = { | |
| format = { | |
| { name = 'uid', type = 'unsigned' }, | |
| { name = 'email', type = 'string' }, | |
| }, | |
| indexes = { | |
| { name = 'primary', parts = { 'uid' } }, | |
| { name = 'email', parts = { 'email', 'uid' } }, | |
| }, | |
| class = require 'User', | |
| }, | |
| accounts = { | |
| format = { | |
| { name = 'id', type = 'string' }, | |
| { name = 'user', type = 'unsigned' }, | |
| { name = 'balance', type = 'unsigned' }, | |
| { name = 'flags', type = 'unsigned' }, | |
| }, | |
| indexes = { | |
| { name = 'primary', parts = { 'id' } }, | |
| { name = 'user', parts = { 'user', 'id' } }, | |
| }, | |
| fk = { | |
| user = 'uid@users', | |
| }, | |
| class = require 'Account', | |
| }, | |
| transactions = { | |
| format = { | |
| { name = 'id', type = 'string' }, | |
| { name = 'account', type = 'string' }, | |
| { name = 'iid', type = 'string' }, -- external ID | |
| { name = 'amount', type = 'unsigned' }, | |
| { name = 'currency', type = 'string' }, | |
| { name = 'status', type = 'string' }, | |
| }, | |
| indexes = { | |
| { name = 'primary', parts = { 'id' } }, | |
| { name = 'iid', parts = { 'iid' } }, | |
| { name = 'account', parts = { 'account', 'id' } }, | |
| { name = 'account_status', parts = { 'account', 'status', 'id' } }, | |
| }, | |
| fk = { | |
| account = 'id@accounts', | |
| }, | |
| class = require 'Transaction', | |
| }, | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment