UNPKG

8.87 kBMarkdownView Raw
1
2
3# backend-plus
4
5Backend for typed-controls
6
7
8![extending](https://img.shields.io/badge/stability-extending-orange.svg)
9[![npm-version](https://img.shields.io/npm/v/backend-plus.svg)](https://npmjs.org/package/backend-plus)
10[![downloads](https://img.shields.io/npm/dm/backend-plus.svg)](https://npmjs.org/package/backend-plus)
11[![build](https://img.shields.io/travis/codenautas/backend-plus/master.svg)](https://travis-ci.org/codenautas/backend-plus)
12[![coverage](https://img.shields.io/coveralls/codenautas/backend-plus/master.svg)](https://coveralls.io/r/codenautas/backend-plus)
13[![climate](https://img.shields.io/codeclimate/github/codenautas/backend-plus.svg)](https://codeclimate.com/github/codenautas/backend-plus)
14[![dependencies](https://img.shields.io/david/codenautas/backend-plus.svg)](https://david-dm.org/codenautas/backend-plus)
15[![qa-control](http://codenautas.com/github/codenautas/backend-plus.svg)](http://codenautas.com/github/codenautas/backend-plus)
16
17
18language: ![English](https://raw.githubusercontent.com/codenautas/multilang/master/img/lang-en.png)
19also available in:
20[![Spanish](https://raw.githubusercontent.com/codenautas/multilang/master/img/lang-es.png)](LEEME.md)
21
22
23
24It's a framework for developing web applications based on PostgreSQL database. It's main features are:
25
26 1. It is based on centralized metadata that defines:
27 1. The data structure (tables and views structure)
28 2. The procedures structure (param definition, permissions, encoding)
29 3. The menus structure
30 2. It provides:
31 1. Editable grids (orderable and filterable), with support for edit data using XLSX format files
32 2. Login mechanism
33 3. Menus
34 4. Skins definition
35
36
37## API
38
39
40### [table definitions](doc/table-definitions.md)
41
42
43
44### [module definitions](doc/module-definitions.md)
45
46
47### [client side definitions](doc/client-side-definitions.md)
48
49### Menus definition
50
51menuType | use
52---------|----------
53menu | menu or submenu
54table | grid or table
55proc | procedures
56
57property | type | default value | menuType | use
58------------|------|----------------|----------|---------
59menuType | T | | | menu Type
60name | T | | | option name (id)
61menuContent | A | | menu | menu content
62table | T | `name` | table | table name
63label | T | `name` | | if you don't want to use default value to display in menu
64
65Integrating example:
66
67```js
68 getMenu(context){
69 return {menu:[
70 {menuType:'menu', name:'periodic table', menuContent:[
71 {menuType:'table', name:'ptable' , label:'elements'},
72 {menuType:'table', name:'pgroups' , label:'groups' },
73 {menuType:'table', name:'isotopes', label:'isotopes'},
74 {menuType:'proc' , name:'count_without_isotopes', label:'count'}
75 ]},
76 {menuType:'table', name:'images', table:'element_images'},
77 {menuType:'menu', name:'test', menuContent:[
78 {menuType:'table', name:'bigint'},
79 ]},
80 {menuType:'menu', name:'config', menuContent:[
81 {name:'users', menuType:'table'},
82 ]},
83 ]}
84 }
85
86```
87### Procedures definition
88
89#### procDef:
90
91property | type | default value | use
92------------|------|-------------------------------|-----------------------------------------------------
93action | T | | Name that will be invoked the procedure
94bitacora | BO | { error:false, always:false } | Bitacora Object for core functions register
95parameters | POA | `[]` | Param Objects Array
96coreFunction| F | | Function that implements the procedure
97
98#### bitacoraDef:
99
100propiedad | tipo | default value | uso
101----------------------------------|----------------|----------------------------|-------------------
102error | B | false | If true, bitacora saves data of error ocurred during core function execution
103always | B | false | If true, bitacora saves all data ocurred during core function execution (overrides error)
104targetTable | T | null | Tablename for update result of execution data (must to exists a record for update) (see **targetTableBitacoraFields**). Use null for ignore option
105targetTableBitacoraFields | O | { **init_date**: 'init_date', **end_date**: 'end_date', **has_error**: 'has_error', **end_status**: 'end_status'} | Objects who defines the fields where **'targetTable'** will reply bitacora fields (If targetTable is null it's ommited)
106targetTableUpdateFieldsCondition | A | null | Fields array to define update condition (each value must to be passed as parameter with the same field name)
107
108
109#### paramDef:
110
111property | type | default value | use
112--------------|----------------|----------------|-------------------
113name | T | | name of the parameter that is sent to the procedure
114defaultValue | según typeName | | parameter default value
115typeName | T | | to define the data type
116label | T | name | if you don't want to use default value to display on screen
117
118#### coreFunction(context, parameters)
119
120context | uso
121---------|----------------------
122be | backendApp object
123username | username
124
125Process definition example:
126
127```js
128 {
129 action:'count_without_isotopes',
130 bitacora:{
131 error:true,
132 always:true,
133 targetTable:'other_table',
134 targetTableBitacoraFields: {
135 init_date: 'fecha_hora_inicio',
136 end_date: 'fecha_hora_final',
137 has_error: 'hubo_error',
138 end_status: 'resultado'
139 },
140 targetTableUpdateFieldsCondition: ['id']
141 },
142 parameters:[
143 {name:'first_atomic_number', defaultValue:10, typeName:'integer'},
144 {name:'last_atomic_number' , defaultValue:99, typeName:'integer'},
145 ],
146 coreFunction:function(context, parameters){
147 return context.client.query(
148 `SELECT count(*) as number_of_elements
149 FROM ptable p left join isotopes i on p.atomic_number=i.atomic_number
150 WHERE i.atomic_number IS NULL
151 AND p.atomic_number between coalesce($1,0) and coalesce($2,999)`,
152 [parameters.first_atomic_number, parameters.last_atomic_number]
153 ).fetchUniqueRow().then(function(result){
154 return result.row.number_of_elements;
155 });
156 }
157 },
158```
159
160## def-config.yaml
161
162entry | usage
163-----------------------------|---------------
164server |
165.module-store |
166install | (see Spanish)
167.dump | (see Spanish)
168..db.owner | (see Spanish)
169..scripts.post-adapt | (see Spanish)
170..scripts.parts-order | (see Spanish)
171devel | (see Spanish)
172.delay | (see Spanish)
173.cache-content | (see Spanish)
174.forceShowAsEditable | (see Spanish)
175login | (see Spanish)
176.plus | (see Spanish)
177..allowHttpLogin | (see Spanish)
178log | (see Spanish)
179.req | (see Spanish)
180.session | (see Spanish)
181client-setup | (see Spanish)
182.cursors | (see Spanish)
183.skin | (see Spanish)
184.menu | (see Spanish)
185.title | (see Spanish)
186.lang | (see Spanish)
187
188```yaml
189install:
190 dump:
191 db:
192 owner: user_owner
193 scripts:
194 post-adapt: [special_triggers.sql, other_constraints.sql]
195login:
196 plus:
197 allowHttpLogin: true
198 store:
199 module-name: file
200log:
201 req: true
202 session: true
203devel:
204 cache-content: true
205```
206
207## Install
208
209```sh
210$ npm install backend-plus
211```
212
213## License
214
215[MIT](LICENSE)
216
217----------------
218
219