generated from liudonghua123/esm-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
4,816 additions
and
381 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,57 @@ | ||
# esm-template | ||
# NaguTriples | ||
|
||
[![Node.js CI](https://github.com/liudonghua123/esm-template/actions/workflows/node.js.yml/badge.svg)](https://github.com/liudonghua123/esm-template/actions/workflows/node.js.yml) | ||
## Introduction | ||
|
||
This is a simple NodeJS template project. | ||
`NaguTriples` implements the persistent storage of triples in the form of `<subject, predicate, object>`。Main features include: | ||
|
||
## Support features | ||
- All parts of the triples are stored as `String` in `UTF-8`, with the maximum length of `512B`. | ||
- The current version is only supports storage in `Mysql`. | ||
|
||
- Default esm module support | ||
- Type support in pure javascript | ||
- Auto doc generation, need to write doc comments | ||
- Format and Lint support | ||
## Installation | ||
|
||
## TODOs | ||
`npm install nagu-triples` | ||
|
||
- [x] Add unit tests | ||
- [x] Add github actions for testing | ||
## Usage | ||
|
||
### 引入包 | ||
|
||
## License | ||
`import triples from 'nagu-triples'` | ||
|
||
MIT License | ||
每一个方法调用都需要带入Mysql的连接信息: | ||
|
||
``` | ||
const options = { | ||
host: '192.168.0.231', | ||
database: 'owl', | ||
user: 'owl', | ||
password: 'password', | ||
port: 3306, | ||
}; | ||
``` | ||
|
||
### 类型 | ||
|
||
#### Notion | ||
三元组中subject, predicate, object 都是一个Notion,Notion是一个对象,包括id和name两个字段。 | ||
|
||
### getOrCreate | ||
|
||
获取或创建一个三元组 | ||
|
||
``` | ||
const trpileId = getOrCreate('a', 'b', 'c', options); | ||
``` | ||
注意: | ||
- 前三个参数分别是subject, predicate, object, 可以是String或Notion(如果传入Notion,将忽略name属性)。 | ||
|
||
### 查询 | ||
|
||
查询函数包括: | ||
- getById | ||
- listByS | ||
- listByP | ||
- listByO | ||
... | ||
|
||
Copyright (c) 2024 liudonghua |
Oops, something went wrong.