1.4.0 • Published 20 hours ago

lambdaorm-cli v1.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
20 hours ago

λORM CLI

λORM CLI is a command line application to use λORM

Installation

Install the package globally to use the CLI commands to help you create and maintain projects

npm install lambdaorm-cli -g

CLI

CommandDescription
versionPrints lambdaorm version this project uses.
initGenerates lambdaorm project structure.
pushSynchronize sources with schema
pullSynchronize schema whit sources
fetchShow differences the schema whit sources
introspectUpdate schema with structure of data and push
incorporateUpdate schema with structure of data, push and importa data
executeExecute an expression lambda.
metadataReturn metadata of query expression.
parametersReturn parameters of query expression.
modelReturn model of query expression.
planReturn plan execution of query expression.
schemaReturn schema information.
importImport data from file to database.
exportExport data from a database.
buildadd configuration, model and repositories according to the language.
dropRemoves all database objects but not the database.

Usage

version

Prints lambdaorm version this project uses.

lambdaorm version

Result:

Global lambdaorm cli version: 0.9.21
Local lambdaorm version: 0.8.96

init

will create the project folder with the basic structure.

lambdaorm init -w lab

It will generate:

├── data
└── lambdaORM.yaml

init client node

will create the project folder with the basic structure.

lambdaorm init -w client-lab -u http://localhost:9291

It will generate:

├── data
└── lambdaORM.yaml

push

Synchronize Stage configured in lambdaORM schema with database/s.

lambdaorm push

In the case the default stage is associated with several data sources, it generates a file for each data source and a file with the current model.

data
├── default-ddl-20231201T191054280Z-push-Catalog.sql
├── default-ddl-20231201T191054280Z-push-Crm.sql
├── default-ddl-20231201T191054281Z-push-Ordering.json
├── default-model.json

execute

Execute an expression lambda.

lambdaorm execute -e .env -q "Orders.filter(p => p.customerId == customerId).include(p => [p.customer.map(p => p.name), p.details.include(p => p.product.include(p => p.category.map(p => p.name)).map(p => p.name)).map(p => [p.quantity, p.unitPrice])]).page(1,1)" -d "{\"customerId\": \"HANAR\"}"

Result:

[
  {
    "id": 3,
    "customerId": "HANAR",
    "employeeId": 4,
    "orderDate": "1996-07-08T00:00:00.000+02:00",
    "requiredDate": "1996-08-05",
    "shippedDate": "1996-07-12",
    "shipViaId": 2,
    "freight": 65.83,
    "name": "Hanari Carnes",
    "address": "Rua do Pao, 67",
    "city": "Rio de Janeiro",
    "region": "RJ",
    "postalCode": "05454-876",
    "country": "Brazil",
    "details": [
      {
        "quantity": 10,
        "unitPrice": 7.7,
        "product": {
          "name": "Jack's New England Clam Chowder",
          "category": {
            "name": "Seafood"
          }
        }
      },
      {
        "quantity": 35,
        "unitPrice": 42.4,
        "product": {
          "name": "Manjimup Dried Apples",
          "category": {
            "name": "Produce"
          }
        }
      },
      {
        "quantity": 15,
        "unitPrice": 16.8,
        "product": {
          "name": "Louisiana Fiery Hot Pepper Sauce",
          "category": {
            "name": "Condiments"
          }
        }
      }
    ],
    "customer": {
      "name": "Hanari Carnes"
    }
  }
]

In this example:

  • The .env file is used to obtain the environment variables.
  • The lambda expression is used to obtain an order from the "HANAR" client.

Plan

Return plan execution of query expression.

lambdaorm plan -e .env -s default -q "Orders.filter(p => p.customerId == customerId).include(p => p.customer.map(p => p.name)).order(p=> p.id).page(1,1)" -o beautiful

Result:

{
  "entity": "Orders",
  "dialect": "MongoDB",
  "source": "Ordering",
  "sentence": "[{ \"$match\" : { \"CustomerID\":{{customerId}} } }, { \"$project\" :{ \"_id\": 0 , \"id\":\"$_id\", \"customerId\":\"$CustomerID\", \"orderDate\":\"$OrderDate\", \"__customerId\":\"$CustomerID\" }} , { \"$sort\" :{ \"_id\":1 } } , { \"$skip\" : 0 }, { \"$limit\" : 1 } , { \"$project\": { \"_id\": 0 } }]",
  "children": [
    {
      "entity": "Customers",
      "dialect": "PostgreSQL",
      "source": "Crm",
      "sentence": "SELECT c.CompanyName AS \"name\", c.CustomerID AS \"LambdaOrmParentId\" FROM Customers c  WHERE  c.CustomerID IN ($1) "
    }
  ]
}

In this example:

  • The .env file is used to obtain the environment variables.
  • The Plan obtained is about the stage default.
  • The lambda expression is used to obtain an order from the "HANAR" client.
  • The plan is obtained in a beautiful format.

import

Import data from file to datasources asociados a un stage.

```bash
lambdaorm import -e .env -s default -d ./data.json

In this example:

  • The datasources associated with the default stage are known.
  • The .env file is used to obtain environment variables.
  • Data is obtained from data.json file

export

Export data from a datasource associated to a stage.

lambdaorm export  -s stage1 -e .env 

In this example:

  • Data is exported from the datasources associated with stage1.
  • The .env file is used to obtain the environment variables.
  • A file called "stage1-export.json" will be created with all the data associated with the stage1 datasources.

Build

Running the build command will create or update the following:

  • Folder that will contain the source code and is taken from the "infrastructure.paths.scr" configuration in the lambdaorm.yaml file
  • Folder that will contain the domain files, the path is relative to the src folder and is taken from the "infrastructure.paths.domain" configuration in the lambdaorm.yaml file
  • Model file: file with the definition of the entities
  • Repository files: one file for each entity with data access methods
  • Install the necessary dependencies according to the databases used

Build Node example

Add configuration, model and repositories according to the language.

lambdaorm build -l node

Result:

├── data
├── lambdaORM.yaml
├── package.json
├── src
│   └── countries
│       └── domain
│           ├── model.ts
│           ├── repositoryCountry.ts
│           └── repositoryState.ts
└── tsconfig.json

Build Client Node example

lambdaorm build -l client-node --all -u http://localhost:9291

Result:

├── data
├── lambdaORM.yaml
├── package.json
├── src
│   ├── index.ts
│   └── northwind
│       └── domain
│           ├── model.ts
│           ├── repositoryCategory.ts
│           ├── repositoryCustomer.ts
│           ├── repositoryOrdersDetail.ts
│           ├── repositoryOrder.ts
│           └── repositoryProduct.ts
└── tsconfig.json

Drop

Removes all database objects but not the database.

lambdaorm drop -e .env -s default
lambdaorm drop -e .env -s insights

Result:

data
├── default-ddl-20231129T110712162Z-push-Catalog.sql
├── default-ddl-20231129T110712163Z-push-Crm.sql
├── default-ddl-20231129T110712163Z-push-Ordering.json
├── default-ddl-20231129T111730593Z-clean-Catalog.sql
├── default-ddl-20231129T111730594Z-clean-Crm.sql
├── default-ddl-20231129T111730594Z-clean-Ordering.json
├── insights-ddl-20231129T110303423Z-push-Insights.sql
└── insights-ddl-20231129T111738316Z-clean-Insights.sql

In this example:

  • The .env file is used to obtain the environment variables.
  • The first execution drops all the database objects associated with the default datasources.
  • The second execution drops all the database objects associated with the insights data sources.
  • The clean files associated with each datasource of each stage are generated.
  • The model file associated with each stage is removed.

Documentation

Full documentation is available in the Wiki.

Related projects

Labs

You can access various labs at github.com/lambda-orm/lambdaorm-labs

1.4.0

20 hours ago

1.3.9

2 days ago

1.3.8

2 days ago

1.3.10

2 days ago

1.3.7

2 days ago

1.3.6

3 days ago

1.3.5

3 days ago

1.3.4

5 days ago

1.2.6

8 days ago

1.2.5

8 days ago

1.2.4

8 days ago

1.2.3

8 days ago

1.3.3

7 days ago

1.3.2

7 days ago

1.3.1

7 days ago

1.3.0

8 days ago

1.2.2

10 days ago

1.2.1

10 days ago

1.2.0

22 days ago

1.1.0

23 days ago

0.9.33

4 months ago

0.9.31

4 months ago

0.9.32

4 months ago

0.9.30

4 months ago

0.9.24

4 months ago

0.9.25

4 months ago

0.9.26

4 months ago

0.9.27

4 months ago

0.9.28

4 months ago

0.9.29

4 months ago

0.9.23

5 months ago

0.9.22

5 months ago

0.9.20

5 months ago

0.9.21

5 months ago

0.9.19

5 months ago

0.8.9

6 months ago

0.8.7

6 months ago

0.9.8

5 months ago

0.9.9

5 months ago

0.9.4

6 months ago

0.9.3

6 months ago

0.9.6

6 months ago

0.9.5

6 months ago

0.8.1

6 months ago

0.8.3

6 months ago

0.8.2

6 months ago

0.9.12

5 months ago

0.9.13

5 months ago

0.9.14

5 months ago

0.9.15

5 months ago

0.9.10

5 months ago

0.9.11

5 months ago

0.9.16

5 months ago

0.9.17

5 months ago

0.9.18

5 months ago

0.9.2

6 months ago

0.9.1

6 months ago

0.8.12

6 months ago

0.8.10

6 months ago

0.7.10

6 months ago

0.7.9

6 months ago

0.7.8

6 months ago

0.7.1

8 months ago

0.7.4

8 months ago

0.7.6

7 months ago

0.7.5

8 months ago

0.7.7

6 months ago

0.6.10-beta

10 months ago

0.6.6-beta

10 months ago

0.6.4-beta

10 months ago

0.6.5-beta

10 months ago

0.6.7-beta

10 months ago

0.4.1-beta

1 year ago

0.4.24-beta

1 year ago

0.4.16-beta

1 year ago

0.4.21-beta

1 year ago

0.4.29-beta

1 year ago

0.4.27-beta

1 year ago

0.4.18-beta

1 year ago

0.4.9-beta

1 year ago

0.4.6-beta

1 year ago

0.4.35-beta

1 year ago

0.4.20-beta

1 year ago

0.4.12-beta

1 year ago

0.4.0-beta

1 year ago

0.4.34-beta

1 year ago

0.4.36-beta

1 year ago

0.4.8-beta

1 year ago

0.4.30-beta

1 year ago

0.4.15-beta

1 year ago

0.4.23-beta

1 year ago

0.4.19-beta

1 year ago

0.4.22-beta

1 year ago

0.4.2-beta

1 year ago

0.4.28-beta

1 year ago

0.3.0-beta

1 year ago

0.2.5-beta

2 years ago

0.2.1-beta

2 years ago

0.2.4-beta

2 years ago

0.2.3-beta

2 years ago

0.2.2-beta

2 years ago

0.1.24-alpha

2 years ago

0.1.27-alpha

2 years ago

0.1.25-alpha

2 years ago

0.1.26-alpha

2 years ago

0.1.23-alpha

2 years ago

0.1.22-alpha

2 years ago

0.1.21-alpha

2 years ago

0.1.9-alpha

2 years ago

0.1.5-alpha

2 years ago

0.1.19-alpha

2 years ago

0.1.7-alpha

2 years ago

0.1.18-alpha

2 years ago

0.1.8-alpha

2 years ago

0.1.20-alpha

2 years ago

0.1.10-alpha

2 years ago

0.1.11-alpha

2 years ago

0.1.6-alpha

2 years ago

0.0.22-alpha

2 years ago

0.0.21-alpha

2 years ago

0.0.20-alpha

2 years ago

0.0.18-alpha

2 years ago

0.0.14-alpha

2 years ago

0.0.17-alpha

2 years ago

0.0.16-alpha

2 years ago

0.0.15-alpha

2 years ago

0.0.14

3 years ago

0.0.12-alpha

3 years ago

0.0.11-alpha

3 years ago

0.0.10-alpha

3 years ago

0.0.9-alpha

3 years ago

0.0.6-alpha

3 years ago

0.0.5-alpha

3 years ago

0.0.2-alpha

3 years ago

0.0.1-alpha

3 years ago