tree-transact

1.3.2 • Public • Published

tree-transact

Build Status NPM version Dependency Status Coverage Status vue version MIT Licence

A transaction system for tree documents for mongoose.

Introduction

Tree document schema:

_id: ObjectId //this (parent) document id
children: // optional array of children
[
 {
     _id: ObjectId //this child document id or reference to document from another collections.
 },
 ...
]

Tree-transact allow:

  • to safely move child subdocuments from one parent document to another;
  • to safely add and remove child subdocuments;
  • to safely change parent document data.

It is guaranteed that child subdocuments will not multiply and will not disappear. If a database or server error occurs, the documents are automatically restored.

It is possible to add additional fields to both the parent and child subdocuments (name, data, collectionName, etc.). Supported child documents from another collections.

How to use tree-transact

Install

npm install tree-transact -S

see the directory containing this source /example/example1.js

Run example

From within the directory containing this source:

npm run example1

Testing

From within the directory containing this source:

npm run test

Warning: Continuous tests with random operations - take a few minutes

Reserved fields in the child schema - do not use in your child schema

tran - transaction object
check - value for check child document exists.

Fork it!

Pull requests, issues, and feedback are welcome.

Package Sidebar

Install

npm i tree-transact

Weekly Downloads

2

Version

1.3.2

License

MIT

Unpacked Size

69.8 kB

Total Files

11

Last publish

Collaborators

  • abernov