|
2 | 2 |
|
3 | 3 | [中文](./README_zh.md) |
4 | 4 |
|
5 | | -Object Relational Mapping for front-ends. |
| 5 | +Object Relational Mapping library built for the front-end, focusing on and **only** focusing on Object Relational Mapping. In other words, it is a library used to convert between **ordinary data objects** and **entities**. |
6 | 6 |
|
7 | | -# What it solves? |
| 7 | +Berry ORM attaches great importance to types, and all features have very strict type support to maximize the advantages of TypeScript. |
8 | 8 |
|
9 | | -Usually, the front-end will not process the data obtained from the back-end, but directly uses these plain objects. In large-scale applications, this can easily lead to extremely complex and messy relation processing code. Berry ORM allows you to access relation objects directly through attributes to avoid the boring relation-processing code. |
| 9 | +Berry ORM is very different from the common ORM libraries in back-ends. The back-end ORM library are usually complete data management solutions, and Object Relational Mapping is only a part of their features. But Berry ORM abides by its duty and is only responsible for mapping the relations between objects, because the data source of front-ends is usually a back-end API or IndexedDB, and there are already countless mature solutions for these data sources, and you can combine the best options to manage Your data. |
10 | 10 |
|
11 | | -Let's take an extreme example: |
12 | | - |
13 | | -When using Berry ORM, you can **directly access the relation objects through the attributes**: |
14 | | - |
15 | | -```ts |
16 | | -user.department.tasks.forEach((task) => { |
17 | | - console.log(task.creator.username); |
18 | | -}); |
19 | | -``` |
20 | | - |
21 | | -While when Berry ORM is not used, you must obtain the relation objects manually according the primary keys: |
22 | | - |
23 | | -```ts |
24 | | -const userDepartment = departmentMap[user.department]; |
25 | | -const departmentTasks = Object.values(taskMap).filter( |
26 | | - (task) => task.department == userDepartment.id, |
27 | | -); |
28 | | -departmentTasks.forEach((task) => { |
29 | | - const taskCreator = userMap[task.creator]; |
30 | | - console.log(taskCreator.username); |
31 | | -}); |
| 11 | +```sh |
| 12 | +npm i berry-orm |
32 | 13 | ``` |
33 | 14 |
|
34 | | -# What it is not? |
| 15 | +# When? |
35 | 16 |
|
36 | | -On the back-end, most _ORM_ libraries are not only responsible for **Object Relational Mapping**, but also include a variety of additional functions such as wrapping database queries, optimization of SQL statements, and so on. But Berry ORM is only responsible for **Object Relation mapping**, it is only responsible for mapping the relations between objects. |
| 17 | +- When you need to centrally store the data obtained from the back-end interface |
| 18 | +- When using IndexedDB to store data in front-ends |
| 19 | +- Anytime you want to access object relations more conveniently! |
37 | 20 |
|
38 | 21 | # Documents |
39 | 22 |
|
|
0 commit comments