Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

Releases: sakuraapi/core

0.19.1

09 Aug 18:41
5e3d31e

Choose a tag to compare

See Milestone 0.19.1

Bug Fix

#231 calls to emitBeforeSave and emitBeforeCreate were not awaiting the async call.

0.19.0

03 Aug 21:11
f1c94fa

Choose a tag to compare

See Milestone 0.19.0

New Features

#225 @BeforeSave and @BeforeCreate can now be manually triggered from model.emitBeforeSave() and model.emitBeforeCreate().
#227 If a model has properties with sub documents represented by child models, the @BeforeSave and @BeforeCreate decorated methods will now be called recursively (parent to child order).

Bug Fixes

#223 IFromJsonOptions is now properly exported
#224 it's now official that if you have a property decorated with both @Db and @Json the correct place to add {mode: SomeModel} is in @Db. @Json decorators will pick up their models from @Db, but not the other way around.

0.18.0

25 Jul 21:45
3bd5745

Choose a tag to compare

What's New?

Models fromJson now supports an optional third parameter, options, which takes an IFromJsonOptions. Currently you can only set sparse. If sparse is set to true, only the json fields passed into fromJson will be included in the resulting model. The model will, however, still have all of its expected methods and functionality.

This feature was introduced to help in situations where you need to convert JSON field names to Model property names, but you don't want the resulting model to have any properties that weren't defined by the JSON input.

0.17.3

22 Jun 23:01
33618d3

Choose a tag to compare

See Milestone 0.17.3

Breaking Change

#218 SakuraApi will not uriEncode connection strings - this causes confusion because MongoDB does not do this automatically, so an integrator likely believes this is his/her responsibility.

0.17.2

25 May 00:52
e9e57e9

Choose a tag to compare

See: Milestone 0.17.2

Bug Fixes

#210 toJson was not properly handling undefined or null values on encrypted properties.

#211 The ability to encrypt and decrypt items directly without toJson/fromJson was missing. These are necessary, for example, in situations where you're receiving an encrypted piece of a large JSON object on a query string.

0.17.1

23 May 16:38
e676933

Choose a tag to compare

Bug Fix

#207 Forgot to include @Id in the roll up for imports.

0.17.0

23 May 01:50
b86916f

Choose a tag to compare

See Milestone 0.17.0

What's new

#201 It's now possible to toggle @Json decorated properties as encryption:true, which causes them to be encrypted toJson and decrypted fromJson using the IJsonOptions.key property to define the cipher key. You can also define @Model({cipherKey: () => 'secret key'}) to define the key at the Model level. The cipherKey function will be called upon instantiation of a model and has access to the models instance via its this context.

#203 @Json({type: 'id'}) will now cause a property to be cast as an ObjectID by fromJson. Future supported types like Date are forthcoming.

Breaking Change

#202 _id must now be explicitly mapped to a property.

  • If you define a dbConfig on your @Model but you do not declare a property decorated with @Id() you will get an error: Failed: Model SomeModelName defines 'dbConfig' but does not have an @Id decorated properties. To resolve this, create a property named something like id: ObjectID; and decorate it with @Id().

  • To get your models back to the equivalent prior behavior (automatically including an id field that mapped to _id and was serializable to json), include the following in your models:

        @Id() @Json({type: 'id'})
        id: ObjectID;
  • the @Id() decorated property is now enumerable. Control its inclusion / exclusion like you would any other property.

Why?(!):

  1. Less magic - it's weird that id is this magical property that's just sorta there.
  2. You can use decorators like @Json({type: 'id'}) on your @Id() decorated property.
  3. This means you can also do things like @Json({encryption: true, type: 'id'}) to encrypt your Ids.

Bug Fixes

#174 - toDb no longer injects undefined: undefined when a property is not decorated with @Db and the @Model is not promiscuous

0.16.0

19 May 21:18
c06eb67

Choose a tag to compare

See Milestone 0.16.0

What's new

  • #136 Generated documentation has been moved out of the project. You can still run npm run docs:serve to build the latest docs locally. You can get API docs for the master and develop branches here: https://github.com/sakuraapi/docs-core
  • #152 calling close on your instance of SakuraApi will now also close your db connections for you
  • #172 Dependencies are now deregistered when you call SakuraApi's close method. You no longer have to call sapi.deregisterDependencies when unit testing. By default, SakuraApi will also no longer throw an error if you do not deregister a dependency between registrations in SakuraApi instances. This is a scenario that normally occurs during testing. To turn this behavior back on, use the throwDependencyAlreadyInjectedError option when instantiating your instance of SakuraApi. (This should also resolve #158).
  • #198 .idea has been included to make it easier for other contributors to match styling and setup.

Breaking Changes

  • #136 npm script doc:serve renamed to docs:serve
  • #152 calling close on your instance of SakuraApi will now also close your db connections for you
  • #172 dependency registration behavior between multiple instances of SakuraApi (usually during testing) has changed

0.15.2

14 May 22:35
527521b

Choose a tag to compare

See: Milestone 0.15.2

Bugs

#190 @Json( { toJson: x } ) was not binding the model to this of the toJson handler. Now it is.
#192 same as #190 but with @ToJson()
#177 @ToJson is now recursively called on child models (@FromJson is not updated yet - see #194)

0.15.1

07 May 17:01
80fca05

Choose a tag to compare

see Milestone 0.15.1

Bug

#188 - projectionFromQuery in 0.15.0 reports invalid_query when you pass in a null / undefined query, but that's a valid query... i.e., no query. This release resolves that issue. projectionFromQuery will now return null when you pass in a null or undefined query.