patternjavascriptMinor
Open source angularjs pouchdb model persistence layer - release ready?
Viewed 0 times
angularjslayerpouchdbsourceopenreadyreleasemodelpersistence
Problem
I'm considering releasing a library as a bower module. Are there issues with code quality, missing test cases, that need to be addressed first? Perhaps it's not a good candidate for public release. If so, why not?
What level of documentation would you want for something like this? I've seen some open source modules publish annotated source, in addition to API documentation. Is annotated source documentation overkill for something like this?
Library Details:
Sample Code (implements the save/update operations):
```
// save or update an object, returns a promise -- ex
What level of documentation would you want for something like this? I've seen some open source modules publish annotated source, in addition to API documentation. Is annotated source documentation overkill for something like this?
Library Details:
- The library provides a simple object persistence layer for Angularjs apps using a local Pouchdb database. It is
$digestaware and promise based. The public API consists of
- setType(type, fn) //register prototype
- newObj() //new object from registered prototype
- saveObj(obj) // insert and update
- getAll(type)
- getById(type,id)
- getByName(type,name)
- getByGQL(query) //TODO: support arbitrary find conditions via Google Query Language
- deleteObj(obj)
- deleteById(id)
- Because the library supports objects that may include functions, the library requires a prototype for each
typebe registered with the library. The prototype is used to re-hydrate de-serialized objects retrieved from the database.
- Evil
new Function()calls are slated to be eliminated by replacing view based queries with their equivalent GQL queries.
- Models are required by Pouchdb to have
_idand_revproperties._idis unique within a database.
- Models are required by the library to have
typeandnameproperties. Currentlynameis enforced to be unique within type. However, thenameconstraint is slated to be removed in favor of an availableuniquemodel validation, allowing any property to act as a unique key.
- Model validation support will include all of validatejs's ActiveRecord style constraints, plus library specific
unique,existsandnotExistsconstraints.
Sample Code (implements the save/update operations):
```
// save or update an object, returns a promise -- ex
Solution
The code looks good (make sure to replace
It is short enough to deserve annotated documentation that would explain how it works which is useful for debugging. But that should not replace the actual API documentation.
new Function quickly :), and it's a great candidate for a public release.It is short enough to deserve annotated documentation that would explain how it works which is useful for debugging. But that should not replace the actual API documentation.
Context
StackExchange Code Review Q#37161, answer score: 2
Revisions (0)
No revisions yet.