Skip to content
Open
26 changes: 13 additions & 13 deletions docs/src/jp/advanced/contribution.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
---
title: Development Guide
title: 開発ガイド
icon: contribute
order: -1
---

We welcome everyone to open Pull Requests for waline! :tada:
waline への Pull Request を歓迎します! :tada:

If you want to contribute to waline, here is a guide.
waline にコントリビュートしたい場合は、以下のガイドをご参照ください。

<!-- more -->

## Preparation
## 準備

1. Use Git to clone the project
1. Git を使ってプロジェクトをクローンします

```bash
git clone https://github.com/walinejs/waline.git
```

1. Installation dependencies
1. 依存関係のインストール

::: warning

Install and use pnpm to install dependencies.
pnpm をインストールし、依存関係のインストールに使用してください。

```bash
npm i -g pnpm@latest
Expand All @@ -35,22 +35,22 @@ If you want to contribute to waline, here is a guide.
pnpm i
```

## Development
## 開発

- Run `pnpm client:dev` to start `@waline/client` devServer
- `pnpm client:dev` を実行して `@waline/client` の開発サーバーを起動します

::: tip

Since waline is based on Client/Server architecture, when debugging a client, you need to set `SERVERURL`, or start server devServer below at the same time and use the default `localhost:9090`.
waline Client/Server アーキテクチャをベースにしているため、クライアントをデバッグする際には `SERVERURL` を設定するか、以下のサーバー開発サーバーを同時に起動してデフォルトの `localhost:9090` を使用する必要があります。

:::

- Run `pnpm server:dev` to start `@waline/server` devServer
- `pnpm server:dev` を実行して `@waline/server` の開発サーバーを起動します

::: tip

In order to run `@waline/server` locally, you need to configure some local environment variables to `.env`.
`@waline/server` をローカルで実行するには、いくつかのローカル環境変数を `.env` に設定する必要があります。

We provide an example for you in `.env.example`.
`.env.example` にサンプルを用意しています。

:::
58 changes: 29 additions & 29 deletions docs/src/jp/advanced/design.md

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions docs/src/jp/advanced/privacy.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
---
title: Privacy Policy
title: プライバシーポリシー
icon: privacy
order: -2
---

Thank you for using the Waline commenting system. We take your privacy and data security very seriously. This privacy policy will inform you how we collect, use, process and protect your personal data.
Waline コメントシステムをご利用いただきありがとうございます。私たちはお客様のプライバシーとデータセキュリティを非常に重視しています。このプライバシーポリシーでは、お客様の個人データをどのように収集・利用・処理・保護するかをご説明します。

## Data Types
## データの種類

In order to provide services, we may collect and store your IP address, browser User-Agent (UA) and other related information, but if you have made the corresponding settings in the Waline configuration file, we will stop storing these according to your request information.
サービスを提供するため、IPアドレス、ブラウザの User-Agent(UA)およびその他の関連情報を収集・保存することがあります。ただし、Waline の設定ファイルで対応する設定を行っている場合は、お客様の要請に従ってこれらの情報の保存を停止します。

## Data Usage
## データの利用

We only use your information to provide commenting services and will not disclose, sell or rent it to third parties. We will make every effort to protect your information security and comply with local laws, regulations and relevant standards.
収集した情報はコメントサービスの提供のみに使用し、第三者への開示・販売・賃貸は行いません。お客様の情報のセキュリティ保護に最善を尽くし、現地の法律・規制および関連する基準を遵守します。

## Data Processing
## データの処理

In order to provide you with better services, we may transmit your information to our servers, partner servers, or third-party service provider's servers, which may be located within or outside the country. We will take reasonable measures to protect your information security and comply with local laws, regulations, and relevant standards.
より良いサービスを提供するため、お客様の情報を当社のサーバー、パートナーのサーバー、またはサードパーティのサービスプロバイダーのサーバーに転送することがあります。これらのサーバーは国内外に所在する場合があります。お客様の情報のセキュリティを保護するための合理的な措置を講じ、現地の法律・規制および関連する基準を遵守します。

## Data Protection
## データの保護

We will take technical and management measures to protect your information security, prevent unauthorized access, use or disclosure. If there are data security issues, we will promptly notify you and take measures to repair them. However, please note that due to the characteristics and technical limitations of the Internet itself, we cannot guarantee 100% security of your information.
お客様の情報のセキュリティを保護し、不正アクセス・利用・開示を防ぐため、技術的・管理的な措置を講じます。データセキュリティに問題が発生した場合は、速やかにお客様に通知し、修復のための措置を講じます。ただし、インターネット自体の特性と技術的な制限により、お客様の情報の 100% の安全を保証することはできません。

## Legal Responsibility
## 法的責任

We will comply with local laws, regulations, and relevant standards to protect the privacy rights and data security of users. If necessary, we may provide user information in accordance with legal requirements. In addition, we will not actively disclose user information.
現地の法律・規制および関連する基準を遵守し、ユーザーのプライバシー権とデータセキュリティを保護します。必要な場合、法的要件に従ってユーザー情報を提供することがあります。また、ユーザー情報を積極的に開示することはありません。

## Other Provisions
## その他の規定

This privacy policy applies to all products and services of the Waline commenting system under default configurations. For additional features added to the Waline commenting system by some websites based on modification, this privacy policy does not guarantee its applicability. We reserve the right to modify the privacy policy and will update it in a timely manner. If you have any questions or suggestions about this privacy policy, please contact us.
このプライバシーポリシーは、デフォルト設定における Waline コメントシステムのすべての製品とサービスに適用されます。一部のウェブサイトが Waline コメントシステムを改変して追加した機能については、このプライバシーポリシーの適用を保証しません。プライバシーポリシーを変更する権利を留保し、変更があった場合は速やかに更新します。このプライバシーポリシーについてご質問やご意見がありましたら、お問い合わせください。
60 changes: 30 additions & 30 deletions docs/src/jp/cookbook/customize/database.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
title: Custom Database Service
title: カスタムデータベースサービス
icon: database
order: -2
---

Waline classifies database operations into several operations such as CURD, and all upper-level logic is completed through the superposition of these basic operations. Through the adapter mode, different types of database storage services only need to implement these low-level atomic operations to run through all system logic.
Waline はデータベース操作を CRUD などのいくつかの操作に分類し、すべての上位ロジックはこれらの基本操作の組み合わせによって完結します。アダプターモードを通じて、異なる種類のデータベースストレージサービスはこれらの低レベルなアトミック操作を実装するだけで、システム全体のロジックを動作させることができます。

```js
// index.js
Expand All @@ -15,7 +15,7 @@ module.exports = Application({
});
```

Waline provides the `model` option to customize the database model, and we will uniformly use the incoming model for database operations. All that remains is that we need to implement this `CustomModel` class.
Waline `model` オプションを提供してデータベースモデルをカスタマイズします。データベース操作には渡されたモデルを統一して使用します。あとは、この `CustomModel` クラスを実装するだけです。

```js
class CustomModel {
Expand Down Expand Up @@ -45,25 +45,25 @@ class CustomModel {
}
```

The above is the basic structure that the `CustomModel` class must implement, and it must include the implementation of several basic methods `select`, `add`, `update`, `delete` and `count`. Waline is developed based on the [ThinkJS](https://thinkjs.org/en) framework, and the underlying database operations use the database operation syntax that comes with the framework. Before implementing these methods, you need to have some basic understanding of the syntax of database conditional queries.
上記は `CustomModel` クラスが実装しなければならない基本的な構造です。`select``add``update``delete``count` のいくつかの基本メソッドの実装を含める必要があります。Waline [ThinkJS](https://thinkjs.org/en) フレームワークをベースに開発されており、下位のデータベース操作にはフレームワーク付属のデータベース操作構文を使用しています。これらのメソッドを実装する前に、データベースの条件クエリの構文について基本的な理解が必要です。

## Condition query
## 条件クエリ

For the complete conditional query syntax, please refer to [ThinkJS Documentation](https://thinkjs.org/jp/doc/3.0/relation_model.html#toc-d47), and the implementation of Waline is a subset of it.
完全な条件クエリの構文については [ThinkJS ドキュメント](https://thinkjs.org/jp/doc/3.0/relation_model.html#toc-d47) を参照してください。Waline の実装はそのサブセットです。

Multiple conditional queries can be passed in through the object, and the default is equal to the condition. When the value is a two-dimensional array, the first bit can be passed to other judgment operations, and the second bit corresponds to the value, such as `{user_id: ['!=', 0]}`. Currently supported are `!=`, `>`, `IN`, `NOT IN`, `LIKE` centralized operations.
オブジェクトを通じて複数の条件クエリを渡すことができ、デフォルトは等値条件です。値が二次元配列の場合、第一要素に他の判定演算子、第二要素に対応する値を渡すことができます(例:`{user_id: ['!=', 0]}`)。現在サポートされている演算子は `!=``>``IN``NOT IN``LIKE` です。

Similar to MySQL, in the `LIKE` operation, we define the mode of the fuzzy query through the position of `%`:
MySQL と同様に、`LIKE` 演算子では `%` の位置によってあいまい検索のモードを定義します:

- `content%` means search for content starting with `content`
- `%content` means search for content ending with `content`
- `%content%` means search for content containing `content`
- `content%` `content` で始まるコンテンツを検索します
- `%content` `content` で終わるコンテンツを検索します
- `%content%` `content` を含むコンテンツを検索します

The conditional query object supports passing in multiple query conditions. The default relationship between these conditions is `AND`, and the `_logic` magic keyword can be used to specify their relationship as `OR`. When there are `AND` and `OR`, we can use `_complex` magic keyword expression.
条件クエリオブジェクトは複数のクエリ条件を渡すことをサポートしています。これらの条件のデフォルトの関係は `AND` であり、`_logic` マジックキーワードを使用して関係を `OR` に指定することができます。`AND` `OR` が混在する場合は、`_complex` マジックキーワードで表現できます。

The text may not be well understood. Let's take a look at the query examples used in the project to deepen our impression.
文章だけではわかりにくいかもしれません。プロジェクトで使用されているクエリ例を見て、理解を深めましょう。

1. General query:
1. 一般的なクエリ:

```js
const model = new CustomModel('Comment');
Expand All @@ -75,7 +75,7 @@ The text may not be well understood. Let's take a look at the query examples use
// SELECT * FROM Comment WHERE url = '/' AND user_id != 0 AND createdAt > "2023-04-16 00:00:00";
```

2. IN / NOT IN query
2. IN / NOT IN クエリ

```js
const model = new CustomModel('Users');
Expand All @@ -89,15 +89,15 @@ The text may not be well understood. Let's take a look at the query examples use
// SELECT * FROM Comment WHERE status NOT IN ('waiting', 'spam');
```

3. LIKE query
3. LIKE クエリ

```js
const model = new CustomModel('Comment');
await model.select({ content: ['LIKE', '%content%'] });
// SELECT * FROM Comment WHERE content LIKE "%content%";
```

4. Multi-condition query
4. 複数条件クエリ

```js
const model = new CustomModel('Comment');
Expand All @@ -110,7 +110,7 @@ The text may not be well understood. Let's take a look at the query examples use
// SELECT * FROM Comment WHERE url = '/' OR user_id != 0 OR createdAt > "2023-04-16 00:00:00";
```

5. Compound query
5. 複合クエリ

```js
const model = new CustomModel('Comment');
Expand All @@ -125,31 +125,31 @@ The text may not be well understood. Let's take a look at the query examples use
// SELECT * FROM Comment WHERE url = '/' AND ( user_id = 0 OR status NOT IN ('waiting', 'spam'));
```

If you are more familiar with TypeScript, [type definitions for conditional queries is here](https://github.com/walinejs/dittorm/blob/master/src/types/where.ts).
TypeScript に慣れている方は、[条件クエリの型定義はこちら](https://github.com/walinejs/dittorm/blob/master/src/types/where.ts)を参照してください。

## Implement query
## クエリの実装

The `select`, `update`, `delete`, `count` methods in the adapter are actually complicated in the conditional query. After understanding the conditional query syntax in the previous part, the subsequent logic is the database operation. surface.
アダプター内の `select``update``delete``count` メソッドは、実際には条件クエリの部分が複雑です。前のパートで条件クエリの構文を理解した上で、残りのロジックはデータベース操作の表面的な部分です。

The `select()` method has a second argument `{desc, limit, offset, field}`. This is also easier to understand:
`select()` メソッドには第二引数 `{desc, limit, offset, field}` があります。これも比較的理解しやすいです:

- `desc`: Specify a field to sort in descending order of the value of the field
- `limit`: specify the number of data returned
- `offset`: Specify the returned data from which item to return
- `field`: Specify the field to return data, all fields are returned by default
- `desc`:フィールドの値の降順でソートするフィールドを指定します
- `limit`:返すデータの件数を指定します
- `offset`:返すデータの開始位置(何件目から返すか)を指定します
- `field`:返すデータのフィールドを指定します。デフォルトはすべてのフィールドを返します

The `update()` method needs to be compatible with scenarios where the `data` input parameter may be a calculation function, such as adding 1 to the number of page viewers:
`update()` メソッドは、`data` 引数が計算関数である場合のシナリオに対応する必要があります。例えば、ページ閲覧数に 1 を加算する場合などです:

```js
const model = new CustomModel('Count');
await model.update((thread) => ({ view: thread.view + 1 }), { url: '/' });
```

Return data type `select()` always returns an array, `add()` and `update()` need to include the full data of the indexed field.
戻り値の型について、`select()` は常に配列を返し、`add()` `update()` はインデックスフィールドを含む完全なデータを返す必要があります。

## refer to
## 参考

Based on the above logic, in addition to implementing the storage service of professional databases, the official also implemented the GitHub storage service very interestingly. We store the data in GitHub in the form of a CSV file, and obtain the content of the CSV file each time we query, and filter out the final data according to the conditional query statement in JS and return it. The following is the official implementation, hoping to give you some reference.
上記のロジックをベースに、公式では専用データベースのストレージサービスの実装に加えて、GitHub ストレージサービスも大変興味深い形で実装されています。データを CSV ファイルの形式で GitHub に保存し、クエリのたびに CSV ファイルの内容を取得し、JS の条件クエリ文に従って最終的なデータをフィルタリングして返します。以下は公式の実装であり、参考にしていただければ幸いです。

```js
//source code: https://github.com/walinejs/waline/blob/main/packages/server/src/service/storage/github.js
Expand Down
Loading
Loading