Skip to content

abernov/Tree-Transact

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A mongoose schema for tree object, supports transactions

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published