github.com/voedger/voedger@v0.0.0-20240520144910-273e84102129/examples/airs-bp/README.md (about)

     1  # airs-bp example
     2  
     3  Prototype of extensions to build airs-bp application
     4  
     5  ## Context
     6  
     7  - [vpm schema](https://github.com/voedger/voedger/issues/1476)
     8  - https://github.com/voedger/voedger/tree/main/staging/src/github.com/voedger/exttinygo
     9  - https://github.com/voedger/voedger/blob/main/pkg/iextenginewazero/_testdata/basicusage/main.go
    10  - https://github.com/untillpro/airs-bp3/blob/2d0d38d1b73f85165a520659cf1e5cad4e67a950/packages/air/pbilldates/impl_fillpbilldates.go#L25
    11  
    12  ## Problems
    13  
    14  - QNames: `IMPORT SCHEMA 'github.com/untillpro/airs-scheme/bp3' AS untill`
    15  - Names conflict: Air, Air_ProformaPrinted
    16  - Query by partial key
    17  - missing function body
    18  - Naming: `articles`, `articles.article_number`
    19    - `schemas.Untill.Articles.MustGetValue(schemas.ID(12))`
    20    - `println(v.Article_number())`
    21    - Solution: semantic analysis shall verify qnames/names uniqueness using case-insensitive mode
    22  ```go
    23  //export hostPanic
    24  func hostPanic(msgPtr, msgSize uint32)
    25  
    26  //export hostRowWriterPutBytes
    27  func hostRowWriterPutBytes(id uint64, typ uint32, namePtr, nameSize, valuePtr, valueSize uint32)
    28  ```
    29  
    30  ## Schemas
    31  
    32  ### airsbp
    33  
    34  https://github.com/untillpro/airs-bp3/blob/main/apps/untill/airsbp/schemas.vsql
    35  
    36  ```sql
    37  -- Copyright (c) 2020-present unTill Pro, Ltd.
    38  -- @author Denis Gribanov
    39  
    40  IMPORT SCHEMA 'github.com/untillpro/airs-scheme/bp3' AS untill;
    41  IMPORT SCHEMA 'github.com/untillpro/airs-bp3/packages/air';
    42  
    43  APPLICATION airsbp (
    44  	USE untill;
    45  	USE air;
    46  );
    47  ```
    48  
    49  ### air
    50  
    51  https://github.com/untillpro/airs-bp3/blob/main/packages/air/air.vsql
    52  
    53  ```sql
    54  -- Copyright (c) 2020-present unTill Pro, Ltd.
    55  -- @author Denis Gribanov
    56  
    57  IMPORT SCHEMA 'github.com/untillpro/airs-scheme/bp3' AS untill;
    58  
    59  WORKSPACE RestaurantWS (
    60  
    61  	TABLE ProformaPrinted INHERITS ODoc (
    62  		Number int32 NOT NULL,
    63  		UserID ref(untill.untill_users) NOT NULL,
    64  		Timestamp int64 NOT NULL,
    65  		BillID ref(untill.bill) NOT NULL
    66  	);
    67  
    68  	VIEW PbillDates (
    69  		Year int32 NOT NULL,
    70  		DayOfYear int32 NOT NULL,
    71  		FirstOffset int64 NOT NULL,
    72  		LastOffset int64 NOT NULL,
    73  		PRIMARY KEY ((Year), DayOfYear)
    74  	) AS RESULT OF FillPbillDates;
    75  
    76  	COMMAND Orders(untill.orders);
    77  
    78  	COMMAND Pbill(untill.pbill) RETURNS CmdPBillResult;
    79  
    80  	TYPE CmdPBillResult (
    81  		Number int32 NOT NULL
    82  	);
    83  
    84  	TABLE NextNumbers INHERITS CSingleton (
    85  		NextPBillNumber int32
    86  	);
    87  
    88  ```
    89  
    90  ### untill
    91  
    92  https://github.com/untillpro/airs-scheme/blob/master/bp3/schema.vsql
    93  
    94  ```sql
    95  
    96  TABLE bill INHERITS WDoc (
    97  	close_datetime int64,
    98  	table_name varchar(50),
    99  	tableno int32 NOT NULL,
   100  	id_untill_users ref(untill_users) NOT NULL,
   101  	table_part varchar(1) NOT NULL,
   102  )
   103  
   104  TABLE articles INHERITS CDoc (
   105  	article_number int32,
   106  	name varchar(255),
   107      ...
   108  )
   109  
   110  TABLE untill_users INHERITS CDoc (
   111  	name varchar(255),
   112  	mandates bytes(10),
   113  	user_void int32 NOT NULL,
   114  	user_code varchar(50),
   115  	user_card varchar(50),
   116  	language varchar(100),
   117      ...
   118  )
   119  
   120  
   121  TABLE pbill INHERITS ODoc (
   122  	id_bill int64 NOT NULL,
   123  	id_untill_users ref(untill_users) NOT NULL,
   124  	number int32,
   125  	pbill_item pbill_item
   126  }
   127  
   128  
   129  TABLE pbill_item INHERITS ORecord (
   130  	id_untill_users ref(untill_users) NOT NULL,
   131  	tableno int32 NOT NULL,
   132  	rowbeg int32 NOT NULL
   133  )
   134  
   135  ```