2.2.4 • Published 4 years ago

@lgslabs/bits-pouch-crud v2.2.4

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
4 years ago

BITS PouchDB CRUD

The PouchDB-backed implementation of CRUD for BITS. This package extends the functionality provided in bits-memory-crud. All items in the collection are expected to be properly-formatted JSON objects with at least an id field.

Use

Importing

npm install @lgslabs/bits-pouch-crud
const {PouchDbCrudService, PouchDbCrudManager, PouchDbCrudMessenger, PouchDbCrudApi, PouchDbCrudRouter} = require('@lgslabs/bits-pouch-crud');

Service

The Service is responsible for creating, loading, and unloading the manager, messenger, router (if desired), a public API (if desired), and any resources the subsystem may need.

createManager

Called in the Service's load function to create the manager. By default, it creates an instance of the base implementation of the PouchDB-backed CRUD manager. If the subsystem needs additional functionality, it is recommended to override this function.

createManager()
  • Returns Promise resolving to request or rejecting to error

Manager

The Manager is responsible for performing any operations related to the subsystem. It has default implementations for all CRUD operations. The manager is an EventEmitter to allow communication with the Messenger. To change the Manager class being used, override the createManager function in the Service to create and return the desired Manager implementation. The loadManager and unloadManager functions can be overridden in the event more customization is required.

_upsertDiff

Helper function which applies the update to the record.

NOTE: this function MUST be synchronous and return the record which will be put into the DB.

_upsertDiff(newItem, oldItem)
  • newItem Object the item to upsert
  • oldItem Object the existing record, or an empty Object if no matching record exists
  • Returns Promise resolving to an object, or rejecting to error
2.2.4

4 years ago

2.2.3

4 years ago

2.2.2

4 years ago

2.2.1

4 years ago

2.2.0

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.0

5 years ago

1.1.0

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago