Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/norjs/database
A client project for JSDoc Configurable Database Service
https://github.com/norjs/database
Last synced: 25 days ago
JSON representation
A client project for JSDoc Configurable Database Service
- Host: GitHub
- URL: https://github.com/norjs/database
- Owner: norjs
- License: mit
- Created: 2019-05-04T18:32:29.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-30T17:36:04.000Z (almost 2 years ago)
- Last Synced: 2024-08-09T02:55:03.053Z (5 months ago)
- Language: JavaScript
- Homepage:
- Size: 82 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @norjs/database
JSDoc Configurable Database Service
### Design
This is a simple document database service implementing a REST interface to a data over a UNIX socket file.
The data can be defined using JSDoc-style configuration files and our
[TypeUtils](https://github.com/norjs/utils#typeutils).### Usage
-------------------------------------------------------------------------------------
First define your custom data objects in a file named `./types.js`:
```js
const TypeUtils = require('@norjs/utils/Type');
/**
* @typedef {Object} MyResourceItemDTO
* @property {number} id - My resource id
* @property {string} name - My resource name
*/
TypeUtils.defineType(
"MyResourceItemDTO",
{
"id": "number",
"name": "string"
}
);/**
* @typedef {Object} MyResourceDTO
* @property {number} id - My resource id
* @property {string} name - My resource name
* @property {boolean} deleted - Deleted or not?
* @property {Array.} items - My items
*/
TypeUtils.defineType(
"MyResourceDTO",
{
"id": "number",
"name": "string",
"deleted": "boolean",
"items": "Array."
}
);```
#### Install
`npm install -g @norjs/database'
#### Start the service:
See [@norjs/database-service](https://github.com/norjs/database-service) about running a service.
#### Create a resource:
```
NODE_CONNECT=./socket.sock \
nor-database --create --set='{"id": 1, "name": "Foo"}'
```#### Get a specific resource:
```
NODE_CONNECT=./socket.sock \
nor-database --get --where='{"id": 1}'
```#### Get a list of resources:
```
NODE_CONNECT=./socket.sock \
nor-database --list
```#### Get a list of resources by name:
```
NODE_CONNECT=./socket.sock \
nor-database --list --where='{"name": "Foo"}'
```#### Update a resource:
```
NODE_CONNECT=./socket.sock \
nor-database --update --set='{"name": "Bar"}' --where='{"id": 1}'
```#### Delete a resource:
```
NODE_CONNECT=./socket.sock \
nor-database --delete --where='{"id": 1}'
```