Skip to content

Commit

Permalink
docs: docsify documentation (#22)
Browse files Browse the repository at this point in the history
* chore: update mongo-objectid + exposed it (#16)

* chore: updated mongo-objectid to 1.2.0

* feat: exposed ObjectID

* test: added exposition test

* chore: updated mongo-objectid to 1.2.1

* chore: bump dependencies to latest

fix security issue.

* fix: consistency issue with getDocument on unfound doc (#15)

Match fs adapter comportment

* chore(package): bump to 3.0.0

* fix: issue with lower fill factor than order for single element tree (#14)

* fix: issue with lower fill factor than order for single element tree (#13)

* fix(SBFRoot/findLowerThan): finding document on equal case for lte

Specific case when order is bigger than actual size

* style: formatting

* test: add tests for tree with lower size than order

Co-authored-by: Anurag Vohra <53807480+anuragvohraec@users.noreply.github.com>

* docs: docsify

Co-authored-by: Anurag Vohra <53807480+anuragvohraec@users.noreply.github.com>
  • Loading branch information
Alex-Werner and anuragvohraec committed Aug 29, 2020
1 parent 2e3bd61 commit 4154eca
Show file tree
Hide file tree
Showing 16 changed files with 559 additions and 358 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Changelog
21 changes: 21 additions & 0 deletions LICENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020+ Alex Werner.

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.
Empty file added docs/.nojekyll
Empty file.
92 changes: 92 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
## SBTree

[![NPM Version](https://img.shields.io/npm/v/sbtree.svg?&style=flat-square)](https://www.npmjs.org/package/sbtree)
[![Build Status](https://api.travis-ci.org/Alex-Werner/SBTree.svg?branch=master)](https://travis-ci.com/Alex-Werner/SBTree)

> Fast document store using B+ Tree for fields. Adapters support for In-Memory and FileSystem
---

SBTree is intended to provide a way to quickly store document-based data in-memory or on the filesystem.
It uses a field-specific indexing system relaying on B+Tree structure.
This allow to handle a lot of data, and have them indexed without the need to keep the whole dataset in-memory.
Most of the databases uses B-Tree (MongoDB, CouchDB) or B+Tree (InnoDB, MariaDB, MySQL).

Note : By default. Everything except specifically excluded field are indexed.
Nested object are also indexed.
Optional support for uniques key provided.

## Install

## Browser

```html
<script src="https://unpkg.com/sbtree"></script>
```

## Node

In order to use this library, you will need to add our [NPM package](https://www.npmjs.com/dash) to your project.

Having [NodeJS](https://nodejs.org/) installed, just type :

```bash
npm install sbtree
```

## Usage


```js
const { SBTree } = require("sbtree");
const tree = new SBTree({order:100});
const start = async function () {
const doc = {_id:'507f1f77bcf86cd799439011',name:"Alex", age:28};
const doc2 = {name:"Jean", age:30}
await tree.insertDocuments(doc);
await tree.insertDocuments(doc2);

// [ { _id: '507f1f77bcf86cd799439011', name: 'Alex', age: 28 } ]
const searchLte = await tree.findDocuments({age:{$lte:28}});
// [ { _id: '507f1f77bcf86cd799439011', name: 'Alex', age: 28 } ] -> equivalent {age:{$eq:28}}
const searchEq = await tree.findDocuments({age:28});

// [ { _id: '507f1f77bcf86cd799439011', name: 'Alex', age: 28 } ]
const [alex] = await tree.getDocument(doc._id);

// [ { _id: '...', name: 'Jean', age: 30 } ]
const deleteRes = await tree.deleteDocuments({age:30});

alex.age = 29;
const replaceRes = await tree.replaceDocuments(alex)

await tree.insertDocuments({name:'John', nestedField:{isNested:{itIs:true}}});
const [john] = await tree.findDocuments({nestedField:{isNested:{itIs:true}}});

}
tree.on('ready', start);

const tree = new SBTree({
network: "testnet",
mnemonic: "arena light cheap control apple buffalo indicate rare motor valid accident isolate",
});

client.isReady().then(async () => {
const {account, platform} = client;
console.log("Funding address", account.getUnusedAddress().address);
console.log("Confirmed Balance", account.getConfirmedBalance());
console.log(await platform.names.get('alice'));
});

```

## Adapters

- `MemoryAdapter` : Default adapter. Set Store inMemory. Limited by heap memory available (good enough).
- `FsAdapter` : Set Data in filesystem. Limitation should be disksize on optimized order.


## Licence

[MIT](https://github.com/Alex-Werner/SBTree/blob/master/LICENCE.md) © Alex Werner

6 changes: 6 additions & 0 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- Primitives
- [SBTree](primitives/SBTree.md)
- Usage
- [Events](usage/events.md)
- [Queries](usage/queries.md)
- [License](LICENSE)
42 changes: 42 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>SBTree - Fast document store using B+ Tree for fields. Adapters support for In-Memory and FileSystem.</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="keywords" content="">
<meta name="description" content="B+Tree document-store for nodejs.">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css">
</head>
<body>
<div id="app"></div>
<script>
window.$docsify = {
alias: {
'.*?/changelog': 'https://raw.githubusercontent.com/Alex-Werner/SBTree/master/CHANGELOG.md',
},
name: 'SBTree',
repo: 'https://github.com/Alex-Werner/SBTree',
loadSidebar: "_sidebar.md",
maxLevel: 4,
subMaxLevel: 2,
search: {
noData: {
'/': 'No results!'
},
paths: 'auto',
placeholder: {
'/': 'Search'
}
},
// search: 'auto',
formatUpdated: '{MM}/{DD} {HH}:{mm}',
themeColor: '#008de4',
}
</script>
<script src="https://cdn.jsdelivr.net/npm/docsify@4"></script>
<script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/docsify-tabs@1"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions docs/api.md → docs/primitives/SBTree.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Allow to fetch a specific document by it's specific id.

Allow to find all documents matching the query

See more info on [queries](/docs/queries.md)
See more info on [queries](/docs/usage/queries.md)


```js
Expand All @@ -46,7 +46,7 @@ See more info on [queries](/docs/queries.md)

Will delete all documents matching the query.

See more info on [queries](/docs/queries.md)
See more info on [queries](/docs/usage/queries.md)

```js
await tree.deleteDocuments({age:33});
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const SBTree = require('./src/types/SBTree/SBTree');
const adapters = require('./src/adapters/index');
const ObjectID = require('mongo-objectid')
const utils = require('./src/utils/index');
module.exports = {SBTree, adapters};
module.exports = {SBTree, ObjectID, adapters};
Loading

0 comments on commit 4154eca

Please sign in to comment.