generated from senecajs/seneca-mem-store
-
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
0 parents
commit 3924113
Showing
22 changed files
with
2,952 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
tmp | ||
dist |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module.exports = { | ||
extends: 'eslint:recommended', | ||
env: { | ||
node: true | ||
}, | ||
parserOptions: { | ||
ecmaVersion: 8 | ||
}, | ||
rules: { | ||
'no-console': 0, | ||
'no-unused-vars': ['error', { 'args': 'none' }], | ||
'yoda': ["error", "always"], | ||
'max-len': ["error", { "code": 80 }], | ||
}, | ||
globals: { | ||
Promise: 'readonly' | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | ||
|
||
name: build | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
build: | ||
timeout-minutes: 6 | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
node-version: [17.x, 16.x, 14.x] | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm install | ||
# manually install peerdeps for node 12,14 | ||
- run: npm i seneca seneca-entity | ||
- run: npm run build --if-present | ||
- run: npm test | ||
|
||
- name: Coveralls | ||
uses: coverallsapp/github-action@master | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
path-to-lcov: ./test/lcov.info |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
lib-cov | ||
*.seed | ||
*.log | ||
*.csv | ||
*.dat | ||
*.out | ||
*.pid | ||
*.gz | ||
|
||
pids | ||
logs | ||
results | ||
|
||
npm-debug.log | ||
node_modules | ||
*~ | ||
.DS_Store | ||
coverage.html | ||
|
||
.history | ||
yarn.lock | ||
package-lock.json | ||
lcov.info | ||
test/coverage.html | ||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*~ | ||
*.off | ||
*-off |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"semi": false, | ||
"singleQuote": true | ||
} |
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
## 6.2.0 - 2021-09-28 | ||
|
||
* Update deps. | ||
|
||
|
||
## 6.0.0 - 2021-05-24 | ||
|
||
* Added upsert support | ||
|
||
|
||
## 5.0.0 - 2020-12-09 | ||
|
||
* Convert to typescript | ||
* Support mongo-style constraints ($gte, $ne, etc.) | ||
|
||
|
||
## 0.6.0 - 2016-08-25 | ||
|
||
* Added Seneca 3 and Node 6 support | ||
* Dropped Node 0.10, 0.12, 5 support | ||
* Updated dependencies | ||
|
||
|
||
## 0.5.1 - 2016-08-09 | ||
|
||
* Updated dependencies | ||
|
||
|
||
## 0.4.0 - 2015-11-25 | ||
|
||
* The memory store follows the specification of seneca stores | ||
* Linted the codebase to folow the seneca styleguide | ||
|
||
|
||
## 0.3.1 - 2015-06-16 | ||
|
||
* Export action responds with object: {json: "..."} | ||
|
||
|
||
## 0.3.0 - 2015-06-16 | ||
|
||
* cmd:import/export no longer uses filesystem, just accepts/provides JSON string. Prep for Seneca 0.6.2. |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015-2016, Richard Rodger and other contributors. | ||
Copyright (c) 2010-2014, Richard Rodger. | ||
|
||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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 |
---|---|---|
@@ -0,0 +1,152 @@ | ||
![Seneca](http://senecajs.org/files/assets/seneca-logo.png) | ||
> A [Seneca.js][] data storage plugin. | ||
# seneca-mem-store | ||
[![npm version][npm-badge]][npm-url] | ||
[![Build](https://github.com/senecajs/seneca-mem-store/actions/workflows/build.yml/badge.svg)](https://github.com/senecajs/seneca-mem-store/actions/workflows/build.yml) | ||
[![Dependency Status][david-badge]][david-url] | ||
[![Maintainability](https://api.codeclimate.com/v1/badges/e2cdcc5415161cb378b0/maintainability)](https://codeclimate.com/github/senecajs/seneca-mem-store/maintainability) | ||
[![DeepScan grade](https://deepscan.io/api/teams/5016/projects/17225/branches/388415/badge/grade.svg)](https://deepscan.io/dashboard#view=project&tid=5016&pid=17225&bid=388415) | ||
[![Coveralls][BadgeCoveralls]][Coveralls] | ||
|
||
|
||
|
||
| ![Voxgig](https://www.voxgig.com/res/img/vgt01r.png) | This open source module is sponsored and supported by [Voxgig](https://www.voxgig.com). | | ||
|---|---| | ||
|
||
|
||
## Description | ||
|
||
This module is a plugin for the Seneca framework. It provides an | ||
in-memory storage engine that provides a set of data storage action | ||
patterns. *Data does not persist betweens runs*. This plugin is most | ||
useful for early development and unit testing. It also provides an | ||
example of a document-oriented storage plugin code-base. | ||
|
||
The Seneca framework provides an [ActiveRecord-style data storage API][]. | ||
Each supported database has a plugin, such as this one, that provides | ||
the underlying Seneca plugin actions required for data persistence. | ||
|
||
This plugin is loaded by default by the [seneca-entity][seneca-entity-url] plugin that also needs the [seneca-basic][seneca-basic-url] plugin to function properly. | ||
|
||
If you're using this module, and need help, you can: | ||
|
||
- Post a [github issue][], | ||
- Tweet to [@senecajs][], | ||
- Ask on the [Gitter][gitter-url]. | ||
|
||
If you are new to Seneca in general, please take a look at [senecajs.org][]. We have everything from | ||
tutorials to sample apps to help get you up and running quickly. | ||
|
||
|
||
## Code examples | ||
|
||
For code samples, please see the [tests][mem-store-tests] for this plugin. | ||
|
||
### Seneca compatibility | ||
Supports Seneca versions **2.x** and above | ||
|
||
|
||
### Supported functionality | ||
All Seneca data store supported functionality is implemented in [seneca-store-test](https://github.com/senecajs/seneca-store-test) as a test suite. The tests represent the store functionality specifications. | ||
|
||
## Install | ||
|
||
```sh | ||
npm install seneca | ||
npm install seneca-mem-store | ||
``` | ||
|
||
You'll need the [seneca](http://github.com/senecajs/seneca) toolkit to use this module - it's just a plugin. | ||
|
||
## Quick Example | ||
|
||
```js | ||
var seneca = require('seneca')() | ||
|
||
seneca.use('basic') | ||
.use('entity') | ||
|
||
// Since mem-store is a default plugin, it does not need to be | ||
// added with .use(). You can just go ahead and use it. | ||
seneca.ready(function () { | ||
var apple = seneca.make$('fruit') | ||
apple.name = 'Pink Lady' | ||
apple.price = 0.99 | ||
|
||
apple.save$(function (err, apple) { | ||
console.log("apple.id = " + apple.id) | ||
}) | ||
}) | ||
``` | ||
|
||
## Usage | ||
You don't use this module directly. It provides an underlying data storage engine for the Seneca entity API: | ||
|
||
```js | ||
var entity = seneca.make$('typename') | ||
entity.someproperty = "something" | ||
entity.anotherproperty = 100 | ||
|
||
entity.save$(function (err, entity) { ... }) | ||
entity.load$({id: ... }, function (err, entity) { ... }) | ||
entity.list$({property: ... }, function (err, entity) { ... }) | ||
entity.remove$({id: ... }, function (err, entity) { ... }) | ||
``` | ||
|
||
### Query Support | ||
The standard Seneca query format is supported: | ||
|
||
- `.list$({f1:v1, f2:v2, ...})` implies pseudo-query `f1==v1 AND f2==v2, ...`. | ||
|
||
- `.list$({f1:v1,...}, {sort$:{field1:1}})` means sort by f1, ascending. | ||
|
||
- `.list$({f1:v1,...}, {sort$:{field1:-1}})` means sort by f1, descending. | ||
|
||
- `.list$({f1:v1,...}, {limit$:10})` means only return 10 results. | ||
|
||
- `.list$({f1:v1,...}, {skip$:5})` means skip the first 5. | ||
|
||
- `.list$({f1:v1,...}, {fields$:['fd1','f2']})` means only return the listed fields. | ||
|
||
Note: you can use `sort$`, `limit$`, `skip$` and `fields$` together. | ||
|
||
### Native Driver | ||
This store is an in memory store and as such does not require the need of a native driver. | ||
|
||
## Contributing | ||
The [Senecajs org][] encourages open participation. If you feel you can help in any way, be it with | ||
documentation, examples, extra testing, or new features please get in touch. | ||
|
||
## Test | ||
To run tests, simply use npm: | ||
|
||
```sh | ||
npm run test | ||
``` | ||
|
||
## License | ||
Copyright (c) 2015-2016, Richard Rodger and other contributors. | ||
Copyright (c) 2010-2014, Richard Rodger. | ||
Licensed under [MIT][]. | ||
|
||
[MIT]: ./LICENSE | ||
[npm-badge]: https://badge.fury.io/js/seneca-mem-store.svg | ||
[npm-url]: https://badge.fury.io/js/seneca-mem-store | ||
[Senecajs org]: https://github.com/senecajs/ | ||
[Seneca.js]: https://www.npmjs.com/package/seneca | ||
[@senecajs]: http://twitter.com/senecajs | ||
[senecajs.org]: http://senecajs.org/ | ||
[travis-badge]: https://travis-ci.org/senecajs/seneca-mem-store.svg | ||
[travis-url]: https://travis-ci.org/senecajs/seneca-mem-store | ||
[gitter-badge]: https://badges.gitter.im/Join%20Chat.svg | ||
[gitter-url]: https://gitter.im/senecajs/seneca | ||
[github issue]: https://github.com/senecajs/seneca-mem-store/issues | ||
[ActiveRecord-style data storage API]:http://senecajs.org/tutorials/understanding-data-entities.html | ||
[david-badge]: https://david-dm.org/senecajs/seneca-mem-store.svg | ||
[david-url]: https://david-dm.org/senecajs/seneca-mem-store | ||
[Coveralls]: https://coveralls.io/github/senecajs/seneca-mem-store?branch=master | ||
[BadgeCoveralls]: https://coveralls.io/repos/github/senecajs/seneca-mem-store/badge.svg?branch=master | ||
[seneca-basic-url]: https://github.com/senecajs/seneca-basic | ||
[seneca-entity-url]: https://github.com/senecajs/seneca-entity | ||
[mem-store-tests]: https://github.com/senecajs/seneca-mem-store/tree/master/test |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export declare class intern { | ||
static is_new(ent: any): boolean; | ||
static is_upsert(msg: any): boolean; | ||
static find_mement(entmap: any, base_ent: any, filter: any): any; | ||
static update_mement(entmap: any, base_ent: any, filter: any, new_attrs: any): any; | ||
static should_merge(ent: any, plugin_opts: any): boolean; | ||
static listents(seneca: any, entmap: any, qent: any, q: any, done: any): void; | ||
static clean_array(ary: string[]): string[]; | ||
static is_object(x: any): boolean; | ||
static is_date(x: any): boolean; | ||
static eq_dates(lv: Date, rv: Date): boolean; | ||
} |
Oops, something went wrong.