Skip to content

Commit

Permalink
Merge pull request #42545 from dinukaamarasinghe817/2201.9.x
Browse files Browse the repository at this point in the history
Update cli help text on bal persist
  • Loading branch information
daneshk authored Apr 15, 2024
2 parents 3905422 + 5dcf340 commit 9eed151
Showing 1 changed file with 35 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@ SYNOPSIS
bal persist <command> [<-h> | <--help>]

DESCRIPTION
Manage data persistence in a Ballerina package.
Manage the data persistence in a Ballerina package.

Initializing the package for persistence is the first step towards achieving
Initializing the package for persistence is the first step toward achieving
data persistence in a Ballerina package. This step creates the required
directories and configuration files.
For example:
directories and updates the configuration files to integrate the generation
of client API into the package build process. For example:

$ bal persist init
$ bal persist add

Defining the application's data model is the next step. Use the generated
definition file in the `persist` directory to define the data model
Define the application's data model as the next step. Use the generated
definition file in the 'persist' directory to define the data model
with the domain-specific entities. Use the standard Ballerina record type
definitions to represent the entities and their relationships.
For example:
definitions to represent entities and their relationships. For example:

type Department record {|
readonly string deptNo;
Expand All @@ -33,21 +32,40 @@ DESCRIPTION
Department department;
|};

Then, generate the client API and SQL script based on the data model. Use the generated
API to query and manipulate the persistent data in the application and use the generated
SQL script to create the database tables.
For example:
Then, generate the client API based on the data model. Use the 'bal build'
command to generate the client API. During project builds, this process
updates the client API whenever modifications are made to the data model.
Use the generated API to query and manipulate the persistent data in the application.

$ bal persist generate
Apart from the above commands, the following commands are also available:

$ bal persist init

This command initializes the package for persistence.
This command will create a new directory named 'persist' in the project
directory. The 'persist' directory will contain empty model definition
file which can be used to define the data model of the Ballerina project.

$ bal persist generate --module persist --datastore mysql

This command generates the client API based on the data model defined in
the 'persist' directory. Usually used for one-time generation of the client API.

OPTIONS
-h, --help
Print the usage details of all commands.

BALLERINA COMMANDS
The available subcommands are listed below.
The below is a list of available subcommands:

init Initialize the package for persistence
generate Generate the client API and SQL script based on the data model defined in the `persist` directory
add Initialize the package for persistence and integrate the
client generation to the 'bal build' command.
init Initialize the package for persistence and create the
'persist' directory and data model file.
generate Generate the client API based on the data model defined
in the 'persist' directory
pull Introspect the existing database schema and generate data model
migrate Generate migration scripts to update the database based
on the data model changes

Use 'bal persist <command> --help' for more information on a specific command.

0 comments on commit 9eed151

Please sign in to comment.