Change:
Document#purgeObsoleteProperties(props, returnIds, shouldCompactIfPurged)
can compact the db file if docs got changed
Added:
- static method
purgeObsoleteProperties()
ofDocument
, allowing to remove properties from the database file when they're no longer part of the schema
Added:
- schema descriptors may have an
"indexed"
flag, ensuring a non-unique index on the respective field
Changes:
- refactored/rewritten pretty much everything
- much stricter schemas
- much more CPU friendly
- removed lodash, only 1 dependency left (
depd
)
Breaking Changes:
- requires Node 14+
- Removed Mongo support (for now)
- Signature of
connect
is nowconnect(nedbUrl, DatastoreClass)
. - Accessing
id
properties ofDocument
orEmbeddedDocument
no longer displays deprecation warnings, but will throw an Error. - Passing a collection name to
new MyDocument(collectionName)
now throws anError
(must overridestatic collectionName()
instead) - Removed deprecated
Document.loadOne()
,loadOneAndUpdate()
,loadOneAndDelete()
,loadMany()
null
values for properties markedrequired
will throw during validation, too- Disallowed wildcard types (
Object
,[]
,Array
,[Object]
). Instead, added cleaner custom type syntax (see #1) - Saving, loading and
Document.toJSON
now strictly adhere to the document's schema, i.e. ignore any instance properties not defined in the class' schema. - strict
Date
handling: numbers and strings assigned toDate
-type properties will no longer be auto-converted toDate
instances before save(), but throwValidationError
instead. Only exception: the schema'sdefault
value (or function return value) may still be string/number and be auto-converted toDate
on Document creation. - Documents now throw by default if created with data containing keys which are
not defined in the schema. This behavior can be customized either globally globally via
setUnknownDataKeyBehavior()
, or by overridingonUnknownData(dataKey, val)
in a derivedDocument
/EmbeddedDocument
class - Deprecated schema definition within constructors (and/or by calling
instance.schema()
). Preferring static fieldSCHEMA
in document classes instead (#2). - Renamed
Client.dropDatabase
toClient._dropDatabase
, marked it "internal" (for testing purposes only) since there is no clean way of safely deleting entire persistent NeDB collections in the filesystem.
Features
- Allow
connect()
to use alternativeDatastore
constructors from any NeDB fork
Breaking Changes
- NeDB is no (optional) dependency anymore, must install manually
Bugfixes:
Bugfixes:
- Merged PR that prevents methods from being serialized in
toJSON()
(#79)
Features:
- Updated README to warn about frequently changing API
- Added Contributing and Contact sections to README Bugfixes:
- Fixed issue that prevented
save()
from being aborted whenPromise.reject
was returned in a hook (#57) - Replaced all
.id
references to._id
in README - Fixed issue where schema types
Array
and[]
were not properly being validated (#53) - In README, changed an incorrect reference of
.findMany()
to.find()
(#54) - Fixed issue where updated nested data wasn't returned when using
.findOneAndUpdate()
with NeDB (#55)
Features:
- Added support for sorting with multiple keys (#22)
- Added support for accepting strings as Dates (#46)
- Deprecated
loadMany
,loadOne
,loadOneAndUpdate
, andloadOneAndDelete
in favor offind
,findOne
,findOneAndUpdate
, andfindOneAndDelete
, respectively (#37) - Added documentation on transpiler support for Camo Bugfixes:
- Changed 'schema({})' to 'this.schema({})' in README since original throws ReferenceError (#52)
Bugfixes:
- Fixed issue with saving/loading deeply nested embedded documents (#35)
- Removed
_id
and_schema._id
fromEmbeddedDocument
class (#31) - Allow user to specify a custom _id (#29)
Features:
- Added new
ValidationError
object Bugfixes: - Improved some validation tests
- Fixed min validation
- Fixed validation for array of embedded documents
- Moved
collectionName
method toBaseDocument
soEmbeddedDocument
can use it (#26) - Deprecated
id
alias from document object (#20) - Fixed serialization test for MongoDB IDs
Bugfixes:
- Fixed issue with running 'canonicalize' tests on travis-ci
Bugfixes:
- Removed unused
harmony-reflect
dependency
Features:
--harmony-proxies
flag is no longer required- Class names now declared in
static collectionName()
. Declaration through constructor is depracated (#16) - Added new
required
schema property (#18 and #19) Bugfixes: - Fixed some inconsistencies with
id
aliasing (partial fix to #20)
Features:
- Added support for setting the 'unique' index on a field
- Added support for specifying which reference fields should be populated in
loadOne()
andloadMany()
Bugfixes: - Fixed issue in
isNativeId
where we weren't returning a proper Boolean.
Features:
- Added support for testing in travis-ci.org Bugfixes:
- Fixed issue #10 where IDs in queries had to be ObjectId. Now string IDs are automatically cast to ObjectId.
Features:
- Added support for
sort
option on.loadMany()
- Added support for
limit
option on.loadMany()
- Added support for
skip
option on.loadMany()
- Added
.toJSON()
toDocument
andEmbeddedDocument
for serialization - Updated 'engines' property to '>=2.0.0' in package.json Bugfixes:
- Fixed issue #14 where
Document
s couldn't be initialized with an array ofEmbeddedDocument
objects via.create()
Features:
- Added support for custom validation on schemas via
validate
property Bugfixes: - Fixed issue #9 where no member values could be set as
undefined
Bugfixes:
- Fixed issue #8 where virtual setters were not used on initialization
loadMany()
now loads all documents if query is not provideddeleteMany()
now deletes all documents if query is not provided
Features:
- Added
loadOneAndUpdate
static method toDocument
class - Added
loadOneAndDelete
static method toDocument
class
Features:
- Added in-memory support for NeDB
- Added regex validator to
Document
Bugfixes:
- Fixed issue where
schema()
wasn't canonicalizing schema definitions. - Updated README to show an example of using
schema()
.
Features:
- README additions
- New test for overriding schemas
Bugfixes:
- Fixed issue where _id was being reassigned in Mongo, and fixed issue with populating references in Mongo.
- Fixed issue with Mongo driver where reference validation checks failed.
- Fixed test Issues.#4 for when running in Mongo.
Bugfixes:
- Fixed issue where
Date
s were saved in different formats (integers,Date
objects, etc). Added way to canonicalize them so all dates look the same in the DB and are also loaded as Date objects.
Bugfixes:
- Fixed issue in
.loadMany()
where references in arrays were getting loaded too many times. (#4).- Added test in issues.test.js
- Fixed issue in
.loadMany()
where muliple references to the same object were only getting loaded once. (#5).- Added test in issues.test.js
- Version bump, thanks to NPM.
Bugfixes:
- Fixed validation and referencing so
Document
s can be referenced by their object or ID.
Features:
- Exposed
getClient()
method for retrieving the active Camo client. - Added
options
parameter toconnect()
so options can be passed to backend DB client. - Static method
Document.fromData()
is now a private helper method. Static method.create()
should be used instead.
Bugfixes:
- In
Document._fromData()
, added check to see if ID exists before assigning - Changed
BaseDocument._fromData()
so it returns data in same form as it was passed.- i.e. Array of data returned as array, single object returned as single object.
- Fixed bug where assigning an array of Documents in
.create()
lost the references. - Stopped using the depracated
_.extend()
alias. Now using_.assign()
instead. (#1). - Fixed
get
andset
issue with Proxy (#3).
Features:
- Changed
.isModel()
to.isDocument()
. - Added
EmbeddedDocument
class and tests.- The following features work with
EmbeddedDocument
s: = Schema options: default, min, max, type, choices = All types supported inDocument
also work inEmbeddedDocument
= Array ofEmbeddedDocument
s = Pre/post validate, save, and delete hooks
- The following features work with
Bugfix:
- Added forked version of
harmony-reflect
. Only difference is it uses a global to ensure it runs only once.
Bugfix:
- Moved Proxy/Reflect shim to index. Seems to fix problem where shim broke Proxies (even worse).
Features:
- Added support for MongoDB using node-mongodb-native as the backend.
- Added
.toCanonicalId()
and.isNativeId()
toDatabaseClient
and its child classes.
- README fix.
Features:
- Added the following Document hooks:
preValidate()
postValidate()
preSave()
postSave()
preDelete()
postDelete()
Features:
- Updated README to include 'javascript' declaration for syntax highlighting.
- Added 'homepage' to package.json.
- Added 'repository' to package.json.
- Added 'email' to 'author' in package.json.
Features:
- Minor version bump.
- No longer need to use
.schema()
in Document subclass. Now all public variables (any variable not starting with an underscore) are used in the schema. - Implemented
.count()
in Document, Client, and NeDbClient to get Document count without retrieving data. - Added
options
parameter to.loadOne()
and.loadMany()
to specify whether references should be populated. - Added support for circular dependencies.
- Added README.
- Added CHANGELOG.
Initial release.