Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ Ballerina Persist Library
[![GitHub Last Commit](https://img.shields.io/github/last-commit/ballerina-platform/module-ballerina-persist.svg)](https://github.com/ballerina-platform/module-ballerina-persist/commits/main)
[![GitHub Issues](https://img.shields.io/github/issues/ballerina-platform/ballerina-standard-library/module/persist.svg?label=Open%20Issues)](https://github.com/ballerina-platform/ballerina-standard-library/labels/module%2Fpersist)

This library provides Ballerina `persist` features, which provides functionality to store and query data conveniently through a data model.
This module provides Ballerina `persist` features, which enable you to store and query data conveniently through a data model.

The `persist` tools provides following functionalities,
The `persist` tools provides the following functionalities,
1. Define and validate the entity data model definitions in the `persist` folder
2. Initialize the Ballerina Persistence Layer for every model definitions in the `persist` folder
3. Generate persistence derived entity types and clients
4. Push persistence schema to the data store (only with supported data sources)
2. Initialize the Ballerina persistence layer for each model definitions in the `persist` folder
3. Generate persistence derived entity types and clients
4. Push persistence schema to the data store (only for supported data sources)
5. Migration support for supported data stores (experimental feature)

## Data Model Definitions
Expand All @@ -37,7 +37,7 @@ An EntityType is defined using `SimpleType` and `EntityType` fields.

> *Note*: The data types for `SimpleType` supported by `persist` will vary by data source. For example, the `byte` type is not supported by MySQL.

This design use fields of type `EntityType` or `EntityType[]` to define associations between two entities.
This design uses fields of type `EntityType` or `EntityType[]` to define associations between two entities.

Here are some examples of entity type definitions:

Expand Down Expand Up @@ -111,7 +111,7 @@ Say type T is a subtype of SimpleType, and T does not contain (),

### Relationship Definition

Ballerina record fields are used to model a connection between two entities. The type of the field should be a subtype of EntityType|EntityType?|EntityType[].
Ballerina record fields are used to model a connection between two entities. The type of the field should be a subtype of `EntityType|EntityType?|EntityType[]`.

This design supports the following cardinalities:
1. One-to-one (1-1)
Expand All @@ -137,7 +137,7 @@ type User record {|
|};
```

The above entities explains the following,
The above entities explain the following,
- A `Car` must have a `User` as the owner.
- A `User` may own a `Car` or do not own one.

Expand All @@ -163,10 +163,10 @@ type User record {|
|};
```

The above entities explains the following,
The above entities explain the following,
- A `Car` must have a `User` as the owner.
- A `User` may own multiple `Car`s or do not own one. (Represented with empty array `[]`)
-
- A `User` may own multiple `Car`s or do not own one. (Represented with empty array `[]`).

The entity that contains the field of type `EntityType` is taken as the owner in the 1-n relationship.

## Issues and projects
Expand Down
27 changes: 14 additions & 13 deletions ballerina/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Module Overview
## Module Overview

This module provides Ballerina `persist` features, which provides functionality to store and query data conveniently through a data model.
This module provides Ballerina `persist` features, which enable you to store and query data conveniently through a data model.

The `persist` tools provides following functionalities,
The `persist` tools provides the following functionalities,
1. Define and validate the entity data model definitions in the `persist` folder
2. Initialize the Ballerina Persistence Layer for every model definitions in the `persist` folder
2. Initialize the Ballerina persistence layer for each model definitions in the `persist` folder
3. Generate persistence derived entity types and clients
4. Push persistence schema to the data store (only with supported data sources)
4. Push persistence schema to the data store (only for supported data sources)
5. Migration support for supported data stores (experimental feature)

## Data Model Definitions
### Data Model Definitions

Within a Ballerina project, the data model should be defined in a separate bal file under the `persist` directory. This file is not considered part of the Ballerina project and is used only for data model definition.

Expand All @@ -20,7 +20,7 @@ The Ballerina `persist` library defines a mechanism to express the application's
An EntityType is defined using `SimpleType` and `EntityType` fields.

```ballerina
// This are the type definitions for the data model when using MySQL
// These are the type definitions for the data model when using MySQL
type SimpleType ()|boolean|int|float|decimal|string|byte[]|time:Date|time:TimeOfDay|time:Utc|time:Civil;
type EntityType record {|
SimpleType|EntityType|EntityType[]...;
Expand All @@ -29,7 +29,7 @@ An EntityType is defined using `SimpleType` and `EntityType` fields.

> *Note*: The data types for `SimpleType` supported by `persist` will vary by data source. For example, the `byte` type is not supported by MySQL.

This design use fields of type `EntityType` or `EntityType[]` to define associations between two entities.
This design uses fields of type `EntityType` or `EntityType[]` to define associations between two entities.

Here are some examples of entity type definitions:

Expand Down Expand Up @@ -66,6 +66,7 @@ type Department record {|
Department department; // EntityType
|};
```

### Entity Attributes Definition

Ballerina record fields are used to model the attributes of an entity. The type of the field should be a subtype of SimpleType.
Expand Down Expand Up @@ -103,7 +104,7 @@ Say type T is a subtype of SimpleType, and T does not contain (),

### Relationship Definition

Ballerina record fields are used to model a connection between two entities. The type of the field should be a subtype of EntityType|EntityType?|EntityType[].
Ballerina record fields are used to model a connection between two entities. The type of the field should be a subtype of `EntityType|EntityType?|EntityType[]`.

This design supports the following cardinalities:
1. One-to-one (1-1)
Expand All @@ -129,7 +130,7 @@ type User record {|
|};
```

The above entities explains the following,
The above entities explain the following,
- A `Car` must have a `User` as the owner.
- A `User` may own a `Car` or do not own one.

Expand All @@ -155,8 +156,8 @@ type User record {|
|};
```

The above entities explains the following,
The above entities explain the following,
- A `Car` must have a `User` as the owner.
- A `User` may own multiple `Car`s or do not own one. (Represented with empty array `[]`)
-
- A `User` may own multiple `Car`s or do not own one. (Represented with empty array `[]`).

The entity that contains the field of type `EntityType` is taken as the owner in the 1-n relationship.