1 | https://shstefanov.github.io/infrastructure/
|
2 |
|
3 | Changes in 1.1.0
|
4 | ================
|
5 |
|
6 | Adding command line options. For parsing is used "minimist".
|
7 | "config" will be detached from options and will be used to update main config tree.
|
8 |
|
9 | # For boolean values:
|
10 | # true
|
11 | > node app.js --config.structures.log.options.sys
|
12 | # false
|
13 | > node app.js --config.structures.log.options.sys false
|
14 |
|
15 | #Specific values
|
16 | > node app.js --config.mongodb.port=27018 --config.mongodb.host=example.com
|
17 |
|
18 | The rest of options will be attached to config.options
|
19 |
|
20 |
|
21 | Adding REPL console, available with --repl option. It starts the console in master process and provides env and config variables.
|
22 | If used as --repl=structure_name in cluster process_mode, it will launch the console in the child process that handles the structure.
|
23 |
|
24 |
|
25 | Fixed spawning on exit in cluster process mode.
|
26 |
|
27 | Seed option for DataLayers
|
28 |
|
29 | --seed or --seed.ModelName
|
30 |
|
31 | This will set seed option to string (url, fs path, related to project root or dot notated config resolve path);
|
32 |
|
33 | --seed.ModelName=http:eample.com/resource
|
34 | --seed.ModelName=./seeds/ModelsData.json
|
35 | --seed.ModelName=seeds.ModelsData
|
36 |
|
37 | The last will be resolved from config tree. It can point to object, array or string that will be proceeded too.
|
38 |
|
39 | It also can point to function (DataLayer instance seed property to be function).
|
40 |
|
41 | function seed(cb){
|
42 | // do something async
|
43 | cb(err, [ /* models here */ ]);
|
44 | }
|
45 |
|
46 | Also, for "http" seeds, if parseSeed provided in DataLayer static properties, it will be used to parse the response.
|
47 |
|
48 | parseSeed: function(body, cb){
|
49 | // scrape response
|
50 | cb(null, [ /* your models here */ ])
|
51 | }
|
52 |
|
53 | Otherwise, parseSeed will be called with resoled data (you may want to make some of properties dates, objectID-s or something else)
|
54 |
|
55 | parseSeed: function(resolved_data, cb){
|
56 | // change the data
|
57 | cb(null, [ /* changed models here */ ])
|
58 | } |
\ | No newline at end of file |