Skip to content

Commit 969eaed

Browse files
committed
Make suggested changes
1 parent dade61f commit 969eaed

File tree

2 files changed

+55
-55
lines changed

2 files changed

+55
-55
lines changed

ballerina/Module.md

+26-26
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This package provides relational database support for the `bal persist` feature, which provides functionality to store and query data from a relational database through a data model instead of writing SQL.
44

5-
Currently, this package supports MySQL, MSSQL and PostgreSQL databases. However, we are also planning to add support for other relational databases such as Oracle.
5+
Currently, this package supports MySQL, MSSQL, and PostgreSQL databases. However, we are also planning to add support for other relational databases such as Oracle.
66

77
## How to use with `bal persist`
88

@@ -61,20 +61,20 @@ The following table lists the Ballerina types supported by the MySQL data store
6161

6262
The following table lists the Ballerina types supported by the MSSQL data store and the corresponding SQL types used to store the data in the database.
6363

64-
| Ballerina type | SQL type |
65-
|:----------------:|:---------------------:|
66-
| int | INT |
67-
| float | FLOAT |
68-
| decimal | DECIMAL(38, 30) |
69-
| string | VARCHAR(191) |
70-
| boolean | BIT |
71-
| byte[] | VARBINARY(MAX) |
72-
| () | NULL |
73-
| time:Date | DATE |
74-
| time:TimeOfDay | TIME |
75-
| time:Utc | DATETIME2 |
76-
| time:Civil | DATETIME2 |
77-
| enum | VARCHAR with checks. |
64+
| Ballerina type | SQL type |
65+
|:----------------:|:--------------------:|
66+
| int | INT |
67+
| float | FLOAT |
68+
| decimal | DECIMAL(38,30) |
69+
| string | VARCHAR(191) |
70+
| boolean | BIT |
71+
| byte[] | VARBINARY(MAX) |
72+
| () | NULL |
73+
| time:Date | DATE |
74+
| time:TimeOfDay | TIME |
75+
| time:Utc | DATETIME2 |
76+
| time:Civil | DATETIME2 |
77+
| enum | VARCHAR with checks. |
7878

7979
### PostgreSQL
8080

@@ -99,17 +99,17 @@ The default length for some SQL types can be changed using the [Advanced SQL typ
9999

100100
## Advanced SQL annotations
101101

102-
To have custom name and type mappings in the database implementation and to declare indexes, generated fields and custom foreign keys, the below annotations can be used in the data model definition. Note that these annotations can only be used with SQL data stores.
102+
To have a custom name and type mappings in the database implementation and to declare indexes, generated fields, and custom foreign keys, the below annotations can be used in the data model definition. Note that these annotations can only be used with SQL data stores.
103103

104104
In order to use them, you must first import the `persist.sql` package to your data model definition file as follows.
105105

106106
```ballerina
107107
import ballerinax/persist.sql;
108108
```
109109

110-
### Mapping names with `Name` annotation
110+
### Name mapping with `Name` annotation
111111

112-
- Map entity names to table names
112+
- Map entity name to table name
113113

114114
```ballerina
115115
@sql:Name {value: "people"}
@@ -122,7 +122,7 @@ type Person record {|
122122

123123
The `Person` entity will be mapped to the `people` table in the database.
124124

125-
- Map field names to column names
125+
- Map field name to column name
126126

127127
```ballerina
128128
type Person record {|
@@ -136,7 +136,7 @@ type Person record {|
136136

137137
The `id` field will be mapped to the `person_id` column in the database, and the `name` field will be mapped to the `full_name` column in the database.
138138

139-
### Mapping types
139+
### Type mapping
140140

141141
#### `Varchar` annotation
142142

@@ -177,7 +177,7 @@ type Person record {|
177177

178178
The `salary` field will have a `DECIMAL(10,2)` column in the database. The `@sql:Decimal` annotation can only be used on `decimal` fields.
179179

180-
### Declaring indexes
180+
### Declare indexes
181181

182182
#### `Index` annotation
183183

@@ -214,7 +214,7 @@ type Person record {|
214214

215215
The unique index `idx_person` is a composite unique index consisting of `nic` and `name` fields. `idx_another` is just another unique index on the `name` field. The `address` field also has the `@sql:UniqueIndex` annotation without the `name` property. Here, the index name will be generated by `persist` in the `unique_idx_[FIELD_NAME]` format, in which case the index name for the `address` field becomes `unique_idx_address`.
216216

217-
### Declaring generated fields with `Generated` annotation
217+
### Declare generated fields with `Generated` annotation
218218

219219
The `@sql:Generated` annotation is used to declare a field as a generated field. This annotation can only be used on `readonly int` fields. Currently, only the `AUTO_INCREMENT` or an equivalent generation strategy is supported.
220220

@@ -235,9 +235,9 @@ The `id` field will be auto-generated and the [`PersonInsert`](/learn/persist-cl
235235
| `MSSQL` | `IDENTITY(1,1)` |
236236
| `PostgreSQL` | `SERIAL` |
237237

238-
### Declaring custom foreign keys with `Relation` annotation
238+
### Declare custom foreign keys with `Relation` annotation
239239

240-
The `@sql:Relation` annotation can be used to declare your own custom foreign key field name. You must put the foreign key on the correct side of the relationship (ownerside) and the key field must exist on the record type, and must be of the same type as the primary key of the referred entity. This is particularly useful when a foreign key is also a part of the composite primary key.
240+
The `@sql:Relation` annotation can be used to declare your own custom foreign key field. You must put the foreign key on the correct side of the relationship (owner) and the key field must exist on the record type, and must be of the same type as the primary key of the referred entity. This is particularly useful when a foreign key is also a part of the composite primary key.
241241

242242
```ballerina
243243
type Car record {|
@@ -255,7 +255,7 @@ type User record {|
255255
|};
256256
```
257257

258-
The `keys` field accepts an array of foreign keys and the length of it must be same as the number of primary keys the referring entity has. Here, the field `userId` is used as the foreign key for the relation `owner` and it has been declared so through the `@sql:Relation` annotation. When the `@sql:Relation` annotation is used in a relation field, the foreign key will not be generated by default.
258+
The `keys` field accepts an array of foreign keys and the length of it must be the same as the number of primary keys the referring entity has. Here, the field `userId` is used as the foreign key for the relation `owner` and it has been declared so through the `@sql:Relation` annotation. When the `@sql:Relation` annotation is used in a relation field, the foreign key will not be generated by default.
259259

260260
## Configuration
261261
You need to set values for the following basic configuration parameters in the `Config.toml` file in your project to use the MySQL data store.
@@ -268,7 +268,7 @@ You need to set values for the following basic configuration parameters in the `
268268
| password | The password of the DB server. |
269269
| database | The name of the database to be used. |
270270

271-
The following is a sample `Config.toml` file with the MySQL data store configuration. This will be generated by the `bal build` or `bal persist generate` command (depending on how you have configured the application).
271+
The following is a sample `Config.toml` file with the MySQL data store configuration. This will be generated by the `bal build` or `bal persist generate` command (depending on how you generate the client API).
272272

273273
```toml
274274
[<packageName>.<moduleName>]

ballerina/Package.md

+29-29
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This package provides relational database support for the `bal persist` feature, which provides functionality to store and query data from a relational database through a data model instead of writing SQL.
44

5-
Currently, this package supports MySQL, MSSQL and PostgreSQL databases. However, we are also planning to add support for other relational databases such as Oracle.
5+
Currently, this package supports MySQL, MSSQL, and PostgreSQL databases. However, we are also planning to add support for other relational databases such as Oracle.
66

77
## How to use with `bal persist`
88

@@ -15,7 +15,7 @@ By default, `bal persist` utilizes the in-memory data store. Therefore, you must
1515
```
1616
$ bal persist add --datastore [mysql/mssql/postgresql] --module <module_name>
1717
```
18-
18+
1919
2. After defining the entities, build the application using the following command,
2020
2121
```
@@ -29,13 +29,13 @@ By default, `bal persist` utilizes the in-memory data store. Therefore, you must
2929
```
3030
$ bal persist init
3131
```
32-
32+
3333
2. Generate the persist client using the following command,
3434
3535
```
3636
$ bal persist generate --datastore [mysql/mssql/postgresql] --module <module_name>
3737
```
38-
38+
3939
## Supported Ballerina Types
4040

4141
### MySQL
@@ -61,20 +61,20 @@ The following table lists the Ballerina types supported by the MySQL data store
6161

6262
The following table lists the Ballerina types supported by the MSSQL data store and the corresponding SQL types used to store the data in the database.
6363

64-
| Ballerina type | SQL type |
65-
|:----------------:|:---------------------:|
66-
| int | INT |
67-
| float | FLOAT |
68-
| decimal | DECIMAL(38, 30) |
69-
| string | VARCHAR(191) |
70-
| boolean | BIT |
71-
| byte[] | VARBINARY(MAX) |
72-
| () | NULL |
73-
| time:Date | DATE |
74-
| time:TimeOfDay | TIME |
75-
| time:Utc | DATETIME2 |
76-
| time:Civil | DATETIME2 |
77-
| enum | VARCHAR with checks. |
64+
| Ballerina type | SQL type |
65+
|:----------------:|:--------------------:|
66+
| int | INT |
67+
| float | FLOAT |
68+
| decimal | DECIMAL(38,30) |
69+
| string | VARCHAR(191) |
70+
| boolean | BIT |
71+
| byte[] | VARBINARY(MAX) |
72+
| () | NULL |
73+
| time:Date | DATE |
74+
| time:TimeOfDay | TIME |
75+
| time:Utc | DATETIME2 |
76+
| time:Civil | DATETIME2 |
77+
| enum | VARCHAR with checks. |
7878

7979
### PostgreSQL
8080

@@ -99,17 +99,17 @@ The default length for some SQL types can be changed using the [Advanced SQL typ
9999

100100
## Advanced SQL annotations
101101

102-
To have custom name and type mappings in the database implementation and to declare indexes, generated fields and custom foreign keys, the below annotations can be used in the data model definition. Note that these annotations can only be used with SQL data stores.
102+
To have a custom name and type mappings in the database implementation and to declare indexes, generated fields, and custom foreign keys, the below annotations can be used in the data model definition. Note that these annotations can only be used with SQL data stores.
103103

104104
In order to use them, you must first import the `persist.sql` package to your data model definition file as follows.
105105

106106
```ballerina
107107
import ballerinax/persist.sql;
108108
```
109109

110-
### Mapping names with `Name` annotation
110+
### Name mapping with `Name` annotation
111111

112-
- Map entity names to table names
112+
- Map entity name to table name
113113

114114
```ballerina
115115
@sql:Name {value: "people"}
@@ -122,7 +122,7 @@ type Person record {|
122122

123123
The `Person` entity will be mapped to the `people` table in the database.
124124

125-
- Map field names to column names
125+
- Map field name to column name
126126

127127
```ballerina
128128
type Person record {|
@@ -136,7 +136,7 @@ type Person record {|
136136

137137
The `id` field will be mapped to the `person_id` column in the database, and the `name` field will be mapped to the `full_name` column in the database.
138138

139-
### Mapping types
139+
### Type mapping
140140

141141
#### `Varchar` annotation
142142

@@ -177,7 +177,7 @@ type Person record {|
177177

178178
The `salary` field will have a `DECIMAL(10,2)` column in the database. The `@sql:Decimal` annotation can only be used on `decimal` fields.
179179

180-
### Declaring indexes
180+
### Declare indexes
181181

182182
#### `Index` annotation
183183

@@ -214,7 +214,7 @@ type Person record {|
214214

215215
The unique index `idx_person` is a composite unique index consisting of `nic` and `name` fields. `idx_another` is just another unique index on the `name` field. The `address` field also has the `@sql:UniqueIndex` annotation without the `name` property. Here, the index name will be generated by `persist` in the `unique_idx_[FIELD_NAME]` format, in which case the index name for the `address` field becomes `unique_idx_address`.
216216

217-
### Declaring generated fields with `Generated` annotation
217+
### Declare generated fields with `Generated` annotation
218218

219219
The `@sql:Generated` annotation is used to declare a field as a generated field. This annotation can only be used on `readonly int` fields. Currently, only the `AUTO_INCREMENT` or an equivalent generation strategy is supported.
220220

@@ -235,9 +235,9 @@ The `id` field will be auto-generated and the [`PersonInsert`](/learn/persist-cl
235235
| `MSSQL` | `IDENTITY(1,1)` |
236236
| `PostgreSQL` | `SERIAL` |
237237

238-
### Declaring custom foreign keys with `Relation` annotation
238+
### Declare custom foreign keys with `Relation` annotation
239239

240-
The `@sql:Relation` annotation can be used to declare your own custom foreign key field name. You must put the foreign key on the correct side of the relationship (ownerside) and the key field must exist on the record type, and must be of the same type as the primary key of the referred entity. This is particularly useful when a foreign key is also a part of the composite primary key.
240+
The `@sql:Relation` annotation can be used to declare your own custom foreign key field. You must put the foreign key on the correct side of the relationship (owner) and the key field must exist on the record type, and must be of the same type as the primary key of the referred entity. This is particularly useful when a foreign key is also a part of the composite primary key.
241241

242242
```ballerina
243243
type Car record {|
@@ -255,7 +255,7 @@ type User record {|
255255
|};
256256
```
257257

258-
The `keys` field accepts an array of foreign keys and the length of it must be same as the number of primary keys the referring entity has. Here, the field `userId` is used as the foreign key for the relation `owner` and it has been declared so through the `@sql:Relation` annotation. When the `@sql:Relation` annotation is used in a relation field, the foreign key will not be generated by default.
258+
The `keys` field accepts an array of foreign keys and the length of it must be the same as the number of primary keys the referring entity has. Here, the field `userId` is used as the foreign key for the relation `owner` and it has been declared so through the `@sql:Relation` annotation. When the `@sql:Relation` annotation is used in a relation field, the foreign key will not be generated by default.
259259

260260
## Configuration
261261
You need to set values for the following basic configuration parameters in the `Config.toml` file in your project to use the MySQL data store.
@@ -268,7 +268,7 @@ You need to set values for the following basic configuration parameters in the `
268268
| password | The password of the DB server. |
269269
| database | The name of the database to be used. |
270270

271-
The following is a sample `Config.toml` file with the MySQL data store configuration. This will be generated by the `bal build` or `bal persist generate` command (depending on how you have configured the application).
271+
The following is a sample `Config.toml` file with the MySQL data store configuration. This will be generated by the `bal build` or `bal persist generate` command (depending on how you generate the client API).
272272

273273
```toml
274274
[<packageName>.<moduleName>]

0 commit comments

Comments
 (0)