Skip to content

Commit 75f948c

Browse files
committed
docs: update README
1 parent 0ff86e5 commit 75f948c

File tree

2 files changed

+18
-52
lines changed

2 files changed

+18
-52
lines changed

README.md

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,21 @@
22

33
[中文](./README_zh.md)
44

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**.
66

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.
88

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.
1010

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
3213
```
3314

34-
# What it is not
15+
# When
3516

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!
3720

3821
# Documents
3922

README_zh.md

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,21 @@
22

33
[English](./README.md)
44

5-
为前端打造的纯粹的对象关系映射
5+
为前端打造的对象关系映射,专注于且****专注于对象关系映射。换句话说,这是一个用来实现**原始数据对象****实体**之间互相转换的一个库。
66

7-
# 它解决了什么?
7+
Berry ORM 非常注重类型,所有的特性都具有非常严格的类型支持,以最大化地发挥 TypeScript 的优势。
88

9-
通常,前端不会对从后端获取到的数据进行很多处理,而是会直接使用这些朴素对象(Plain Object)。在大型的应用中,这很容易导致**关系处理**变得异常复杂而凌乱。而 Berry ORM 可以让你**直接通过属性来访问关系对象**,省去无聊的手动关系处理过程
9+
Berry ORM 与后端常见的 ORM 库有很大的不同。后端的 ORM 库通常是一套完整的数据管理方案,映射对象间的关系只是其中的一部分功能。但 Berry ORM 恪守本分,仅仅负责映射对象间的关系,因为前端源通常是后端接口或 IndexedDB,而对于这些数据源已经存在无数成熟的解决方案了,你可以组合出最佳的选择来管理你的数据
1010

11-
让我们来举一个极端一点的例子:
12-
13-
当使用 Berry ORM 时,可以**直接通过属性来访问关系对象**
14-
15-
```ts
16-
user.department.tasks.forEach((task) => {
17-
console.log(task.creator.username);
18-
});
19-
```
20-
21-
当不使用 Berry ORM 时,关系通常由主键来表示,需要凭借主键手动获取关系对象:
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
3213
```
3314

34-
# 它不是什么
15+
# 什么时候需要
3516

36-
在后端,*ORM*库大多不仅负责**对象关系映射**,还包括了对数据库查询的包装、对 SQL 语句的优化等等众多额外的功能。但 Berry ORM 仅仅负责**对象关系映射**这一项,它仅仅负责映射对象间的关系。
17+
- 需要集中存储从后端接口获取的数据时
18+
- 使用 IndexedDB 在前端存储数据时
19+
- 想要更方便地访问对象关系的任何时候!
3720

3821
# 文档
3922

0 commit comments

Comments
 (0)