From f173c26652062d71e5b69268bedf9e6ae8d61d3d Mon Sep 17 00:00:00 2001 From: Danesh Kuruppu Date: Sun, 25 Aug 2024 20:29:08 +0530 Subject: [PATCH 1/2] Update the examples and fix the line break issue --- examples/persist-create/persist_create.md | 10 ++++------ examples/persist-create/persist_generate.out | 5 ++--- examples/persist-create/persist_init.out | 12 ++++++------ examples/persist-delete/persist_delete.md | 10 ++++------ examples/persist-delete/persist_generate.out | 5 ++--- examples/persist-delete/persist_init.out | 12 ++++++------ examples/persist-filtering/persist_filtering.md | 10 ++++------ examples/persist-filtering/persist_generate.out | 5 ++--- examples/persist-filtering/persist_init.out | 12 ++++++------ examples/persist-get-all/persist_generate.out | 5 ++--- examples/persist-get-all/persist_get_all.md | 7 +++---- examples/persist-get-all/persist_init.out | 12 ++++++------ examples/persist-get-by-key/persist_generate.out | 5 ++--- examples/persist-get-by-key/persist_get_by_key.md | 10 ++++------ examples/persist-get-by-key/persist_init.out | 12 ++++++------ .../persist-relation-queries/persist_generate.out | 5 ++--- examples/persist-relation-queries/persist_init.out | 12 ++++++------ .../persist_relation_queries.md | 10 ++++------ examples/persist-select-fields/persist_generate.out | 5 ++--- examples/persist-select-fields/persist_init.out | 12 ++++++------ .../persist-select-fields/persist_select_fields.md | 10 ++++------ examples/persist-update/persist_generate.out | 5 ++--- examples/persist-update/persist_init.out | 12 ++++++------ examples/persist-update/persist_update.md | 10 ++++------ 24 files changed, 95 insertions(+), 118 deletions(-) diff --git a/examples/persist-create/persist_create.md b/examples/persist-create/persist_create.md index ee520d9b69..ae31855aad 100644 --- a/examples/persist-create/persist_create.md +++ b/examples/persist-create/persist_create.md @@ -1,10 +1,9 @@ # Persist write - Create record/records -The bal persist feature provides support to manage data persistence in a Ballerina package. It starts with defining the application's data model. Once the model is defined, the client API is generated with resources based on the model. The generated -API can be used to query and manipulate the persistent data in the application. +The bal persist feature provides support to manage data persistence in a Ballerina package. It starts with defining the application's data model. Once the model is defined, the client API is generated with resources based on the model. The generated API can be used to query and manipulate the persistent data in the application. The generated client API provides a `post` resource method to persist record/records to the data store. -> **Note:** This example uses the Ballerina tables as the data store. You can use MySQL and Google Sheets as the data store as well. For more information, see [Supported Data Stores](/learn/supported-data-stores/). +> **Note:** This example uses the Ballerina tables as the data store. For more information about other supported data stores, see [Supported Data Stores](/learn/supported-data-stores/). #### Initialize the project Execute the command below to initialize `bal persist` in the project. @@ -12,24 +11,23 @@ Execute the command below to initialize `bal persist` in the project. ::: out persist_init.out ::: #### Model the data - Add the `Employee` entity with the following fields in the `model.bal` file inside the `persist` directory. ::: code persist_model.bal ::: #### Generate client APIs +> **Note:** The client APIs can be generated using the `bal persist generate` command which is one time generation and the generated client code is a part of the project. We can also integrate the client code generation with the build process of the project by executing the `bal persist add` command. This will add the client code generation as a build task in the `Ballerina.toml` file. For more information, see [Persist CLI Commands](learn/persist-cli-tool/). + Execute the command below to generate the Ballerina client API. ::: out persist_generate.out ::: #### Use the generated client API - Using the generated client API, you can persist record/records to the data store with the `post` resource method. ::: code persist_create.bal ::: #### Run the program - Execute the command below to run the program. ::: out persist_create.out ::: diff --git a/examples/persist-create/persist_generate.out b/examples/persist-create/persist_generate.out index af0cd91d23..a60f5d2169 100644 --- a/examples/persist-create/persist_generate.out +++ b/examples/persist-create/persist_generate.out @@ -1,4 +1,3 @@ -$ bal persist generate +$ bal persist generate --datastore inmemory --module store -Generated Ballerina Client, Types, and Scripts to ./generated/store directory. -You can now start using Ballerina Client in your code. +Persist client and entity types generated successfully in the store directory. diff --git a/examples/persist-create/persist_init.out b/examples/persist-create/persist_init.out index 41d568a6d1..66347477ba 100644 --- a/examples/persist-create/persist_init.out +++ b/examples/persist-create/persist_init.out @@ -1,9 +1,9 @@ -$ bal persist init --module store +$ bal persist init -Initialized persistence in your Ballerina project. - -Your Persist schema is at persist/model.bal. -You can now update it with entity definitions. +Initialized the package for persistence. Next steps: -Run bal persist generate to generate the Ballerina Client, Types, and Scripts. You can then start querying your database. +1. Define your data model in "persist/model.bal". +2. Execute `bal persist add --datastore --module ` to add an entry to "Ballerina.toml" for integrating code generation with the package build process. +OR +Execute `bal persist generate --datastore --module ` for a one-time generation of the client. diff --git a/examples/persist-delete/persist_delete.md b/examples/persist-delete/persist_delete.md index 61f675142b..e43895d752 100644 --- a/examples/persist-delete/persist_delete.md +++ b/examples/persist-delete/persist_delete.md @@ -1,10 +1,9 @@ # Persist write - Delete record -The bal persist feature provides support to manage data persistence in a Ballerina package. It starts with defining the application's data model. Once the model is defined, the client API is generated with resources based on the model. The generated -API can be used to query and manipulate the persistent data in the application. +The bal persist feature provides support to manage data persistence in a Ballerina package. It starts with defining the application's data model. Once the model is defined, the client API is generated with resources based on the model. The generated API can be used to query and manipulate the persistent data in the application. The generated client API provides a `delete` resource method to delete records from the data store. -> **Note:** This example uses Ballerina tables as the data store. You can use MySQL and Google Sheets as the data store as well. For more information, see [Supported Data Stores](/learn/supported-data-stores/). +> **Note:** This example uses the Ballerina tables as the data store. For more information about other supported data stores, see [Supported Data Stores](/learn/supported-data-stores/). #### Initialize the project Execute the command below to initialize `bal persist` in the project. @@ -12,24 +11,23 @@ Execute the command below to initialize `bal persist` in the project. ::: out persist_init.out ::: #### Model the data - Add `Employee` entity with the following fields in the `model.bal` file inside the `persist` directory. ::: code persist_model.bal ::: #### Generate client APIs +> **Note:** The client APIs can be generated using the `bal persist generate` command which is one time generation and the generated client code is a part of the project. We can also integrate the client code generation with the build process of the project by executing the `bal persist add` command. This will add the client code generation as a build task in the `Ballerina.toml` file. For more information, see [Persist CLI Commands](learn/persist-cli-tool/). + Execute the command below to generate the Ballerina client API. ::: out persist_generate.out ::: #### Use the generated client API - Using the generated client API, you can delete records from the data store with the `delete` resource method. ::: code persist_delete.bal ::: #### Run the program - Execute the command below to run the program. ::: out persist_delete.out ::: diff --git a/examples/persist-delete/persist_generate.out b/examples/persist-delete/persist_generate.out index af0cd91d23..a60f5d2169 100644 --- a/examples/persist-delete/persist_generate.out +++ b/examples/persist-delete/persist_generate.out @@ -1,4 +1,3 @@ -$ bal persist generate +$ bal persist generate --datastore inmemory --module store -Generated Ballerina Client, Types, and Scripts to ./generated/store directory. -You can now start using Ballerina Client in your code. +Persist client and entity types generated successfully in the store directory. diff --git a/examples/persist-delete/persist_init.out b/examples/persist-delete/persist_init.out index 41d568a6d1..66347477ba 100644 --- a/examples/persist-delete/persist_init.out +++ b/examples/persist-delete/persist_init.out @@ -1,9 +1,9 @@ -$ bal persist init --module store +$ bal persist init -Initialized persistence in your Ballerina project. - -Your Persist schema is at persist/model.bal. -You can now update it with entity definitions. +Initialized the package for persistence. Next steps: -Run bal persist generate to generate the Ballerina Client, Types, and Scripts. You can then start querying your database. +1. Define your data model in "persist/model.bal". +2. Execute `bal persist add --datastore --module ` to add an entry to "Ballerina.toml" for integrating code generation with the package build process. +OR +Execute `bal persist generate --datastore --module ` for a one-time generation of the client. diff --git a/examples/persist-filtering/persist_filtering.md b/examples/persist-filtering/persist_filtering.md index e204558e04..9345b90eff 100644 --- a/examples/persist-filtering/persist_filtering.md +++ b/examples/persist-filtering/persist_filtering.md @@ -1,10 +1,9 @@ # Persist read - Filter and sort -The bal persist feature provide support to manage data persistence in a Ballerina package. It starts with defining the application's data model. Once model is defined, the client API is generated with resources based on the model. The generated -API can be used to query and manipulate the persistent data in the application. +The bal persist feature provide support to manage data persistence in a Ballerina package. It starts with defining the application's data model. Once model is defined, the client API is generated with resources based on the model. The generated API can be used to query and manipulate the persistent data in the application. The generated client API provides `get` resource method to retrieve all records from the data store. As the `get` resource method returns a stream of records, we can use query expressions to do additional filter. For more information, see [Query Expressions](/learn/by-example/query-expressions/). -> **Note:** This example uses Ballerina tables as the data store. You can use MySQL and Google Sheets as the data store as well. For more information, see [Supported Data Stores](/learn/supported-data-stores/). +> **Note:** This example uses the Ballerina tables as the data store. For more information about other supported data stores, see [Supported Data Stores](/learn/supported-data-stores/). #### Initialize the project Execute the command below to initialize `bal persist` in the project. @@ -12,24 +11,23 @@ Execute the command below to initialize `bal persist` in the project. ::: out persist_init.out ::: #### Model the data - Add `Employee` entity with the following fields in the `model.bal` file inside the `persist` directory. ::: code persist_model.bal ::: #### Generate client APIs +> **Note:** The client APIs can be generated using the `bal persist generate` command which is one time generation and the generated client code is a part of the project. We can also integrate the client code generation with the build process of the project by executing the `bal persist add` command. This will add the client code generation as a build task in the `Ballerina.toml` file. For more information, see [Persist CLI Commands](learn/persist-cli-tool/). + Execute the command below to generate the Ballerina client API. ::: out persist_generate.out ::: #### Use the generated client API - Using the generated client API, we can retrieve all records from the data store. The `get` resource method returns a stream of records. We can iterate through the stream and print the records. ::: code persist_filtering.bal ::: #### Run the program - Execute the command below to run the program. ::: out persist_filtering.out ::: diff --git a/examples/persist-filtering/persist_generate.out b/examples/persist-filtering/persist_generate.out index af0cd91d23..a60f5d2169 100644 --- a/examples/persist-filtering/persist_generate.out +++ b/examples/persist-filtering/persist_generate.out @@ -1,4 +1,3 @@ -$ bal persist generate +$ bal persist generate --datastore inmemory --module store -Generated Ballerina Client, Types, and Scripts to ./generated/store directory. -You can now start using Ballerina Client in your code. +Persist client and entity types generated successfully in the store directory. diff --git a/examples/persist-filtering/persist_init.out b/examples/persist-filtering/persist_init.out index 41d568a6d1..66347477ba 100644 --- a/examples/persist-filtering/persist_init.out +++ b/examples/persist-filtering/persist_init.out @@ -1,9 +1,9 @@ -$ bal persist init --module store +$ bal persist init -Initialized persistence in your Ballerina project. - -Your Persist schema is at persist/model.bal. -You can now update it with entity definitions. +Initialized the package for persistence. Next steps: -Run bal persist generate to generate the Ballerina Client, Types, and Scripts. You can then start querying your database. +1. Define your data model in "persist/model.bal". +2. Execute `bal persist add --datastore --module ` to add an entry to "Ballerina.toml" for integrating code generation with the package build process. +OR +Execute `bal persist generate --datastore --module ` for a one-time generation of the client. diff --git a/examples/persist-get-all/persist_generate.out b/examples/persist-get-all/persist_generate.out index af0cd91d23..a60f5d2169 100644 --- a/examples/persist-get-all/persist_generate.out +++ b/examples/persist-get-all/persist_generate.out @@ -1,4 +1,3 @@ -$ bal persist generate +$ bal persist generate --datastore inmemory --module store -Generated Ballerina Client, Types, and Scripts to ./generated/store directory. -You can now start using Ballerina Client in your code. +Persist client and entity types generated successfully in the store directory. diff --git a/examples/persist-get-all/persist_get_all.md b/examples/persist-get-all/persist_get_all.md index d0dca5bd1e..7c3240295b 100644 --- a/examples/persist-get-all/persist_get_all.md +++ b/examples/persist-get-all/persist_get_all.md @@ -4,7 +4,7 @@ The bal persist feature provides support to manage data persistence in a Balleri The generated client API provides a `get` resource method to retrieve all records from the data store. -> **Note:** This example uses Ballerina tables as the data store. You can use MySQL and Google Sheets as the data store as well. For more information, see [Supported Data Stores](/learn/supported-data-stores/). +> **Note:** This example uses the Ballerina tables as the data store. For more information about other supported data stores, see [Supported Data Stores](/learn/supported-data-stores/). #### Initialize the project Execute the command below to initialize `bal persist` in the project. @@ -12,24 +12,23 @@ Execute the command below to initialize `bal persist` in the project. ::: out persist_init.out ::: #### Model the data - Add `Employee` entity with the following fields in the `model.bal` file inside the `persist` directory. ::: code persist_model.bal ::: #### Generate client APIs +> **Note:** The client APIs can be generated using the `bal persist generate` command which is one time generation and the generated client code is a part of the project. We can also integrate the client code generation with the build process of the project by executing the `bal persist add` command. This will add the client code generation as a build task in the `Ballerina.toml` file. For more information, see [Persist CLI Commands](learn/persist-cli-tool/). + Execute the command below to generate the Ballerina client API. ::: out persist_generate.out ::: #### Use the generated client API - Using the generated client API, we can retrieve all records from the data store. The `get` resource method returns a stream of records. We can iterate through the stream and print the records. ::: code persist_get_all.bal ::: #### Run the program - Execute the command below to run the program. ::: out persist_get_all.out ::: diff --git a/examples/persist-get-all/persist_init.out b/examples/persist-get-all/persist_init.out index 41d568a6d1..66347477ba 100644 --- a/examples/persist-get-all/persist_init.out +++ b/examples/persist-get-all/persist_init.out @@ -1,9 +1,9 @@ -$ bal persist init --module store +$ bal persist init -Initialized persistence in your Ballerina project. - -Your Persist schema is at persist/model.bal. -You can now update it with entity definitions. +Initialized the package for persistence. Next steps: -Run bal persist generate to generate the Ballerina Client, Types, and Scripts. You can then start querying your database. +1. Define your data model in "persist/model.bal". +2. Execute `bal persist add --datastore --module ` to add an entry to "Ballerina.toml" for integrating code generation with the package build process. +OR +Execute `bal persist generate --datastore --module ` for a one-time generation of the client. diff --git a/examples/persist-get-by-key/persist_generate.out b/examples/persist-get-by-key/persist_generate.out index af0cd91d23..a60f5d2169 100644 --- a/examples/persist-get-by-key/persist_generate.out +++ b/examples/persist-get-by-key/persist_generate.out @@ -1,4 +1,3 @@ -$ bal persist generate +$ bal persist generate --datastore inmemory --module store -Generated Ballerina Client, Types, and Scripts to ./generated/store directory. -You can now start using Ballerina Client in your code. +Persist client and entity types generated successfully in the store directory. diff --git a/examples/persist-get-by-key/persist_get_by_key.md b/examples/persist-get-by-key/persist_get_by_key.md index 705e4328a7..8245c36dd8 100644 --- a/examples/persist-get-by-key/persist_get_by_key.md +++ b/examples/persist-get-by-key/persist_get_by_key.md @@ -1,10 +1,9 @@ # Persist read - Get record by key -The bal persist feature provides support to manage data persistence in a Ballerina package. It starts with defining the application's data model. Once the model is defined, the client API is generated with resources based on the model. The generated -API can be used to query and manipulate the persistent data in the application. +The bal persist feature provides support to manage data persistence in a Ballerina package. It starts with defining the application's data model. Once the model is defined, the client API is generated with resources based on the model. The generated API can be used to query and manipulate the persistent data in the application. The generated client API provides `get by key` resource method to retrieve the record by the key from the data store. -> **Note:** This example uses Ballerina tables as the data store. You can use MySQL and Google Sheets as the data store as well. For more information, see [Supported Data Stores](/learn/supported-data-stores/). +> **Note:** This example uses the Ballerina tables as the data store. For more information about other supported data stores, see [Supported Data Stores](/learn/supported-data-stores/). #### Initialize the project Execute the command below to initialize `bal persist` in the project. @@ -12,24 +11,23 @@ Execute the command below to initialize `bal persist` in the project. ::: out persist_init.out ::: #### Model the data - Add `Employee` entity with the following fields in the `model.bal` file inside the `persist` directory. ::: code persist_model.bal ::: #### Generate client APIs +> **Note:** The client APIs can be generated using the `bal persist generate` command which is one time generation and the generated client code is a part of the project. We can also integrate the client code generation with the build process of the project by executing the `bal persist add` command. This will add the client code generation as a build task in the `Ballerina.toml` file. For more information, see [Persist CLI Commands](learn/persist-cli-tool/). + Execute the command below to generate the Ballerina client API. ::: out persist_generate.out ::: #### Use the generated client API - Using the generated client API, you can retrieve the record by key from the data store. The `get by key` resource method returns a record or error if no records are found for the given key. ::: code persist_get_by_key.bal ::: #### Run the program - Execute the command below to run the program. ::: out persist_get_by_key.out ::: diff --git a/examples/persist-get-by-key/persist_init.out b/examples/persist-get-by-key/persist_init.out index 41d568a6d1..66347477ba 100644 --- a/examples/persist-get-by-key/persist_init.out +++ b/examples/persist-get-by-key/persist_init.out @@ -1,9 +1,9 @@ -$ bal persist init --module store +$ bal persist init -Initialized persistence in your Ballerina project. - -Your Persist schema is at persist/model.bal. -You can now update it with entity definitions. +Initialized the package for persistence. Next steps: -Run bal persist generate to generate the Ballerina Client, Types, and Scripts. You can then start querying your database. +1. Define your data model in "persist/model.bal". +2. Execute `bal persist add --datastore --module ` to add an entry to "Ballerina.toml" for integrating code generation with the package build process. +OR +Execute `bal persist generate --datastore --module ` for a one-time generation of the client. diff --git a/examples/persist-relation-queries/persist_generate.out b/examples/persist-relation-queries/persist_generate.out index af0cd91d23..a60f5d2169 100644 --- a/examples/persist-relation-queries/persist_generate.out +++ b/examples/persist-relation-queries/persist_generate.out @@ -1,4 +1,3 @@ -$ bal persist generate +$ bal persist generate --datastore inmemory --module store -Generated Ballerina Client, Types, and Scripts to ./generated/store directory. -You can now start using Ballerina Client in your code. +Persist client and entity types generated successfully in the store directory. diff --git a/examples/persist-relation-queries/persist_init.out b/examples/persist-relation-queries/persist_init.out index 41d568a6d1..66347477ba 100644 --- a/examples/persist-relation-queries/persist_init.out +++ b/examples/persist-relation-queries/persist_init.out @@ -1,9 +1,9 @@ -$ bal persist init --module store +$ bal persist init -Initialized persistence in your Ballerina project. - -Your Persist schema is at persist/model.bal. -You can now update it with entity definitions. +Initialized the package for persistence. Next steps: -Run bal persist generate to generate the Ballerina Client, Types, and Scripts. You can then start querying your database. +1. Define your data model in "persist/model.bal". +2. Execute `bal persist add --datastore --module ` to add an entry to "Ballerina.toml" for integrating code generation with the package build process. +OR +Execute `bal persist generate --datastore --module ` for a one-time generation of the client. diff --git a/examples/persist-relation-queries/persist_relation_queries.md b/examples/persist-relation-queries/persist_relation_queries.md index 512db99031..b0528091c9 100644 --- a/examples/persist-relation-queries/persist_relation_queries.md +++ b/examples/persist-relation-queries/persist_relation_queries.md @@ -1,10 +1,9 @@ # Persist read - Relation queries -The bal persist feature provides support to manage data persistence in a Ballerina package. It starts with defining the application's data model. Once the model is defined, the client API is generated with resources based on the model. The generated -API can be used to query and manipulate the persistent data in the application. +The bal persist feature provides support to manage data persistence in a Ballerina package. It starts with defining the application's data model. Once the model is defined, the client API is generated with resources based on the model. The generated API can be used to query and manipulate the persistent data in the application. The generated client API provides support to select fields in relational entities when retrieving the records/record from the `get` resource method from the data store. -> **Note:** This example uses Ballerina tables as the data store. You can use MySQL and Google Sheets as the data store as well. For more information, see [Supported Data Stores](/learn/supported-data-stores/). +> **Note:** This example uses the Ballerina tables as the data store. For more information about other supported data stores, see [Supported Data Stores](/learn/supported-data-stores/). #### Initialize the project Execute the command below to initialize persistence in the project. @@ -12,24 +11,23 @@ Execute the command below to initialize persistence in the project. ::: out persist_init.out ::: #### Model the data - Add `Employee`, `Department`, `Workspace`, and `Building` entities with relations in between in the `model.bal` file inside the `persist` directory. ::: code persist_model.bal ::: #### Generate client APIs +> **Note:** The client APIs can be generated using the `bal persist generate` command which is one time generation and the generated client code is a part of the project. We can also integrate the client code generation with the build process of the project by executing the `bal persist add` command. This will add the client code generation as a build task in the `Ballerina.toml` file. For more information, see [Persist CLI Commands](learn/persist-cli-tool/). + Execute the command below to generate the Ballerina client API. ::: out persist_generate.out ::: #### Use the generated client API - Using the generated client API, you can retrieve the record with relations from the data store with both `get` and `get by key` resource methods. ::: code persist_relation_queries.bal ::: #### Run the program - Execute the command below to run the program. ::: out persist_relation_queries.out ::: diff --git a/examples/persist-select-fields/persist_generate.out b/examples/persist-select-fields/persist_generate.out index af0cd91d23..a60f5d2169 100644 --- a/examples/persist-select-fields/persist_generate.out +++ b/examples/persist-select-fields/persist_generate.out @@ -1,4 +1,3 @@ -$ bal persist generate +$ bal persist generate --datastore inmemory --module store -Generated Ballerina Client, Types, and Scripts to ./generated/store directory. -You can now start using Ballerina Client in your code. +Persist client and entity types generated successfully in the store directory. diff --git a/examples/persist-select-fields/persist_init.out b/examples/persist-select-fields/persist_init.out index 41d568a6d1..66347477ba 100644 --- a/examples/persist-select-fields/persist_init.out +++ b/examples/persist-select-fields/persist_init.out @@ -1,9 +1,9 @@ -$ bal persist init --module store +$ bal persist init -Initialized persistence in your Ballerina project. - -Your Persist schema is at persist/model.bal. -You can now update it with entity definitions. +Initialized the package for persistence. Next steps: -Run bal persist generate to generate the Ballerina Client, Types, and Scripts. You can then start querying your database. +1. Define your data model in "persist/model.bal". +2. Execute `bal persist add --datastore --module ` to add an entry to "Ballerina.toml" for integrating code generation with the package build process. +OR +Execute `bal persist generate --datastore --module ` for a one-time generation of the client. diff --git a/examples/persist-select-fields/persist_select_fields.md b/examples/persist-select-fields/persist_select_fields.md index 19d381fcb1..343043612c 100644 --- a/examples/persist-select-fields/persist_select_fields.md +++ b/examples/persist-select-fields/persist_select_fields.md @@ -1,10 +1,9 @@ # Persist read - Select fields -The bal persist feature provides support to manage data persistence in a Ballerina package. It starts with defining the application's data model. Once the model is defined, the client API is generated with resources based on the model. The generated -API can be used to query and manipulate the persistent data in the application. +The bal persist feature provides support to manage data persistence in a Ballerina package. It starts with defining the application's data model. Once the model is defined, the client API is generated with resources based on the model. The generated API can be used to query and manipulate the persistent data in the application. The generated client API provides support to select a subset of fields of the entity when retrieving the records/record from the `get` resource method from the data store. -> **Note:** This example uses Ballerina tables as the data store. You can use MySQL and Google Sheets as the data store as well. For more information, see [Supported Data Stores](/learn/supported-data-stores/). +> **Note:** This example uses the Ballerina tables as the data store. For more information about other supported data stores, see [Supported Data Stores](/learn/supported-data-stores/). #### Initialize the project Execute the command below to initialize `bal persist` in the project. @@ -12,24 +11,23 @@ Execute the command below to initialize `bal persist` in the project. ::: out persist_init.out ::: #### Model the data - Add `Employee` entity with the following fields in the `model.bal` file inside the `persist` directory. ::: code persist_model.bal ::: #### Generate client APIs +> **Note:** The client APIs can be generated using the `bal persist generate` command which is one time generation and the generated client code is a part of the project. We can also integrate the client code generation with the build process of the project by executing the `bal persist add` command. This will add the client code generation as a build task in the `Ballerina.toml` file. For more information, see [Persist CLI Commands](learn/persist-cli-tool/). + Execute the command below to generate the Ballerina client API. ::: out persist_generate.out ::: #### Use the generated client API - Using the generated client API, you can retrieve the record with selected fields from the data store with both `get` and `get by key` resource methods. ::: code persist_select_fields.bal ::: #### Run the program - Execute the command below to run the program. ::: out persist_select_fields.out ::: diff --git a/examples/persist-update/persist_generate.out b/examples/persist-update/persist_generate.out index af0cd91d23..a60f5d2169 100644 --- a/examples/persist-update/persist_generate.out +++ b/examples/persist-update/persist_generate.out @@ -1,4 +1,3 @@ -$ bal persist generate +$ bal persist generate --datastore inmemory --module store -Generated Ballerina Client, Types, and Scripts to ./generated/store directory. -You can now start using Ballerina Client in your code. +Persist client and entity types generated successfully in the store directory. diff --git a/examples/persist-update/persist_init.out b/examples/persist-update/persist_init.out index 41d568a6d1..66347477ba 100644 --- a/examples/persist-update/persist_init.out +++ b/examples/persist-update/persist_init.out @@ -1,9 +1,9 @@ -$ bal persist init --module store +$ bal persist init -Initialized persistence in your Ballerina project. - -Your Persist schema is at persist/model.bal. -You can now update it with entity definitions. +Initialized the package for persistence. Next steps: -Run bal persist generate to generate the Ballerina Client, Types, and Scripts. You can then start querying your database. +1. Define your data model in "persist/model.bal". +2. Execute `bal persist add --datastore --module ` to add an entry to "Ballerina.toml" for integrating code generation with the package build process. +OR +Execute `bal persist generate --datastore --module ` for a one-time generation of the client. diff --git a/examples/persist-update/persist_update.md b/examples/persist-update/persist_update.md index fbc110958d..3dc3dcd121 100644 --- a/examples/persist-update/persist_update.md +++ b/examples/persist-update/persist_update.md @@ -1,10 +1,9 @@ # Persist write - Update record -The bal persist feature provides support to manage data persistence in a Ballerina package. It starts with defining the application's data model. Once the model is defined, the client API is generated with resources based on the model. The generated -API can be used to query and manipulate the persistent data in the application. +The bal persist feature provides support to manage data persistence in a Ballerina package. It starts with defining the application's data model. Once the model is defined, the client API is generated with resources based on the model. The generated API can be used to query and manipulate the persistent data in the application. The generated client API provides a `put` resource method to update the record in the data store. -> **Note:** This example uses Ballerina tables as the data store. You can use MySQL and Google Sheets as the data store as well. For more information, see [Supported Data Stores](/learn/supported-data-stores/). +> **Note:** This example uses the Ballerina tables as the data store. For more information about other supported data stores, see [Supported Data Stores](/learn/supported-data-stores/). #### Initialize the project Execute the command below to initialize `bal persist` in the project. @@ -12,24 +11,23 @@ Execute the command below to initialize `bal persist` in the project. ::: out persist_init.out ::: #### Model the data - Add `Employee` entity with the following fields in the `model.bal` file inside the `persist` directory. ::: code persist_model.bal ::: #### Generate client APIs +> **Note:** The client APIs can be generated using the `bal persist generate` command which is one time generation and the generated client code is a part of the project. We can also integrate the client code generation with the build process of the project by executing the `bal persist add` command. This will add the client code generation as a build task in the `Ballerina.toml` file. For more information, see [Persist CLI Commands](learn/persist-cli-tool/). + Execute the command below to generate the Ballerina client API. ::: out persist_generate.out ::: #### Use the generated client API - Using the generated client API, you can update the record in the data store with the `put` resource method. ::: code persist_update.bal ::: #### Run the program - Execute the command below to run the program. ::: out persist_update.out ::: From 5ca97b5525edcff00c205b4e212f913e7c9dd875 Mon Sep 17 00:00:00 2001 From: Danesh Kuruppu Date: Mon, 9 Sep 2024 13:27:34 +0530 Subject: [PATCH 2/2] restructure the description base on the review --- examples/persist-create/persist_create.md | 4 ++-- examples/persist-delete/persist_delete.md | 5 +++-- examples/persist-filtering/persist_filtering.md | 4 ++-- examples/persist-get-all/persist_get_all.md | 4 ++-- examples/persist-get-by-key/persist_get_by_key.md | 4 ++-- .../persist-relation-queries/persist_relation_queries.md | 4 ++-- examples/persist-select-fields/persist_select_fields.md | 4 ++-- examples/persist-update/persist_update.md | 4 ++-- 8 files changed, 17 insertions(+), 16 deletions(-) diff --git a/examples/persist-create/persist_create.md b/examples/persist-create/persist_create.md index ae31855aad..39b947912d 100644 --- a/examples/persist-create/persist_create.md +++ b/examples/persist-create/persist_create.md @@ -16,12 +16,12 @@ Add the `Employee` entity with the following fields in the `model.bal` file insi ::: code persist_model.bal ::: #### Generate client APIs -> **Note:** The client APIs can be generated using the `bal persist generate` command which is one time generation and the generated client code is a part of the project. We can also integrate the client code generation with the build process of the project by executing the `bal persist add` command. This will add the client code generation as a build task in the `Ballerina.toml` file. For more information, see [Persist CLI Commands](learn/persist-cli-tool/). - Execute the command below to generate the Ballerina client API. ::: out persist_generate.out ::: +> **Note:** The `bal persist generate` command is a one-time generation task, and the generated client code is a part of the project. We can also integrate the client code generation with the project's build process by executing the `bal persist add` command. This command will add the client code generation as a build task in the `Ballerina.toml` file. See [Persist CLI Commands](learn/persist-cli-tool/) for more information. + #### Use the generated client API Using the generated client API, you can persist record/records to the data store with the `post` resource method. diff --git a/examples/persist-delete/persist_delete.md b/examples/persist-delete/persist_delete.md index e43895d752..4d9d0b5cda 100644 --- a/examples/persist-delete/persist_delete.md +++ b/examples/persist-delete/persist_delete.md @@ -16,12 +16,13 @@ Add `Employee` entity with the following fields in the `model.bal` file inside t ::: code persist_model.bal ::: #### Generate client APIs -> **Note:** The client APIs can be generated using the `bal persist generate` command which is one time generation and the generated client code is a part of the project. We can also integrate the client code generation with the build process of the project by executing the `bal persist add` command. This will add the client code generation as a build task in the `Ballerina.toml` file. For more information, see [Persist CLI Commands](learn/persist-cli-tool/). - Execute the command below to generate the Ballerina client API. ::: out persist_generate.out ::: +> **Note:** The `bal persist generate` command is a one-time generation task, and the generated client code is a part of the project. We can also integrate the client code generation with the project's build process by executing the `bal persist add` command. This command will add the client code generation as a build task in the `Ballerina.toml` file. See [Persist CLI Commands](learn/persist-cli-tool/) for more information. + + #### Use the generated client API Using the generated client API, you can delete records from the data store with the `delete` resource method. diff --git a/examples/persist-filtering/persist_filtering.md b/examples/persist-filtering/persist_filtering.md index 9345b90eff..99af98aab9 100644 --- a/examples/persist-filtering/persist_filtering.md +++ b/examples/persist-filtering/persist_filtering.md @@ -16,12 +16,12 @@ Add `Employee` entity with the following fields in the `model.bal` file inside t ::: code persist_model.bal ::: #### Generate client APIs -> **Note:** The client APIs can be generated using the `bal persist generate` command which is one time generation and the generated client code is a part of the project. We can also integrate the client code generation with the build process of the project by executing the `bal persist add` command. This will add the client code generation as a build task in the `Ballerina.toml` file. For more information, see [Persist CLI Commands](learn/persist-cli-tool/). - Execute the command below to generate the Ballerina client API. ::: out persist_generate.out ::: +> **Note:** The `bal persist generate` command is a one-time generation task, and the generated client code is a part of the project. We can also integrate the client code generation with the project's build process by executing the `bal persist add` command. This command will add the client code generation as a build task in the `Ballerina.toml` file. See [Persist CLI Commands](learn/persist-cli-tool/) for more information. + #### Use the generated client API Using the generated client API, we can retrieve all records from the data store. The `get` resource method returns a stream of records. We can iterate through the stream and print the records. diff --git a/examples/persist-get-all/persist_get_all.md b/examples/persist-get-all/persist_get_all.md index 7c3240295b..5ed68f55b6 100644 --- a/examples/persist-get-all/persist_get_all.md +++ b/examples/persist-get-all/persist_get_all.md @@ -17,12 +17,12 @@ Add `Employee` entity with the following fields in the `model.bal` file inside t ::: code persist_model.bal ::: #### Generate client APIs -> **Note:** The client APIs can be generated using the `bal persist generate` command which is one time generation and the generated client code is a part of the project. We can also integrate the client code generation with the build process of the project by executing the `bal persist add` command. This will add the client code generation as a build task in the `Ballerina.toml` file. For more information, see [Persist CLI Commands](learn/persist-cli-tool/). - Execute the command below to generate the Ballerina client API. ::: out persist_generate.out ::: +> **Note:** The `bal persist generate` command is a one-time generation task, and the generated client code is a part of the project. We can also integrate the client code generation with the project's build process by executing the `bal persist add` command. This command will add the client code generation as a build task in the `Ballerina.toml` file. See [Persist CLI Commands](learn/persist-cli-tool/) for more information. + #### Use the generated client API Using the generated client API, we can retrieve all records from the data store. The `get` resource method returns a stream of records. We can iterate through the stream and print the records. diff --git a/examples/persist-get-by-key/persist_get_by_key.md b/examples/persist-get-by-key/persist_get_by_key.md index 8245c36dd8..32cdc330f5 100644 --- a/examples/persist-get-by-key/persist_get_by_key.md +++ b/examples/persist-get-by-key/persist_get_by_key.md @@ -16,12 +16,12 @@ Add `Employee` entity with the following fields in the `model.bal` file inside t ::: code persist_model.bal ::: #### Generate client APIs -> **Note:** The client APIs can be generated using the `bal persist generate` command which is one time generation and the generated client code is a part of the project. We can also integrate the client code generation with the build process of the project by executing the `bal persist add` command. This will add the client code generation as a build task in the `Ballerina.toml` file. For more information, see [Persist CLI Commands](learn/persist-cli-tool/). - Execute the command below to generate the Ballerina client API. ::: out persist_generate.out ::: +> **Note:** The `bal persist generate` command is a one-time generation task, and the generated client code is a part of the project. We can also integrate the client code generation with the project's build process by executing the `bal persist add` command. This command will add the client code generation as a build task in the `Ballerina.toml` file. See [Persist CLI Commands](learn/persist-cli-tool/) for more information. + #### Use the generated client API Using the generated client API, you can retrieve the record by key from the data store. The `get by key` resource method returns a record or error if no records are found for the given key. diff --git a/examples/persist-relation-queries/persist_relation_queries.md b/examples/persist-relation-queries/persist_relation_queries.md index b0528091c9..2dd6ddeaef 100644 --- a/examples/persist-relation-queries/persist_relation_queries.md +++ b/examples/persist-relation-queries/persist_relation_queries.md @@ -16,12 +16,12 @@ Add `Employee`, `Department`, `Workspace`, and `Building` entities with relation ::: code persist_model.bal ::: #### Generate client APIs -> **Note:** The client APIs can be generated using the `bal persist generate` command which is one time generation and the generated client code is a part of the project. We can also integrate the client code generation with the build process of the project by executing the `bal persist add` command. This will add the client code generation as a build task in the `Ballerina.toml` file. For more information, see [Persist CLI Commands](learn/persist-cli-tool/). - Execute the command below to generate the Ballerina client API. ::: out persist_generate.out ::: +> **Note:** The `bal persist generate` command is a one-time generation task, and the generated client code is a part of the project. We can also integrate the client code generation with the project's build process by executing the `bal persist add` command. This command will add the client code generation as a build task in the `Ballerina.toml` file. See [Persist CLI Commands](learn/persist-cli-tool/) for more information. + #### Use the generated client API Using the generated client API, you can retrieve the record with relations from the data store with both `get` and `get by key` resource methods. diff --git a/examples/persist-select-fields/persist_select_fields.md b/examples/persist-select-fields/persist_select_fields.md index 343043612c..79418cc941 100644 --- a/examples/persist-select-fields/persist_select_fields.md +++ b/examples/persist-select-fields/persist_select_fields.md @@ -16,12 +16,12 @@ Add `Employee` entity with the following fields in the `model.bal` file inside t ::: code persist_model.bal ::: #### Generate client APIs -> **Note:** The client APIs can be generated using the `bal persist generate` command which is one time generation and the generated client code is a part of the project. We can also integrate the client code generation with the build process of the project by executing the `bal persist add` command. This will add the client code generation as a build task in the `Ballerina.toml` file. For more information, see [Persist CLI Commands](learn/persist-cli-tool/). - Execute the command below to generate the Ballerina client API. ::: out persist_generate.out ::: +> **Note:** The `bal persist generate` command is a one-time generation task, and the generated client code is a part of the project. We can also integrate the client code generation with the project's build process by executing the `bal persist add` command. This command will add the client code generation as a build task in the `Ballerina.toml` file. See [Persist CLI Commands](learn/persist-cli-tool/) for more information. + #### Use the generated client API Using the generated client API, you can retrieve the record with selected fields from the data store with both `get` and `get by key` resource methods. diff --git a/examples/persist-update/persist_update.md b/examples/persist-update/persist_update.md index 3dc3dcd121..2fe4ca2434 100644 --- a/examples/persist-update/persist_update.md +++ b/examples/persist-update/persist_update.md @@ -16,12 +16,12 @@ Add `Employee` entity with the following fields in the `model.bal` file inside t ::: code persist_model.bal ::: #### Generate client APIs -> **Note:** The client APIs can be generated using the `bal persist generate` command which is one time generation and the generated client code is a part of the project. We can also integrate the client code generation with the build process of the project by executing the `bal persist add` command. This will add the client code generation as a build task in the `Ballerina.toml` file. For more information, see [Persist CLI Commands](learn/persist-cli-tool/). - Execute the command below to generate the Ballerina client API. ::: out persist_generate.out ::: +> **Note:** The `bal persist generate` command is a one-time generation task, and the generated client code is a part of the project. We can also integrate the client code generation with the project's build process by executing the `bal persist add` command. This command will add the client code generation as a build task in the `Ballerina.toml` file. See [Persist CLI Commands](learn/persist-cli-tool/) for more information. + #### Use the generated client API Using the generated client API, you can update the record in the data store with the `put` resource method.