Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 3, 2024. It is now read-only.

License

NotificationsYou must be signed in to change notification settings

normalized-db/denormalizer

Repository files navigation

Warning

This project has been deprecated in favor of@normalized-db/ndb.

DenormalizeJavaScript objects from a normalized data structure based on a simple schema(implemented withTypeScript).

Versioning

To ease versioning equal major and minor version numbers are used for all modules.

Installation

Install using NPM:

npm install --save @normalized-db/denormalizer

Usage

Use theDenormalizerBuilder to create aDenormalizer. Use eitherschema(…) orschemaConfig(…) to apply aschema configuration. This is the only required parameter. IfnormalizedData does not contain an object which isneeded during denormalization then theDenormalizer will try to lazy load it usingfetchCallback. TheKeyMapis a helper with a mapping from primary keys to the index of the related object in the normalized data.

To actually denormalize an object or an array of objects use either…

  • applyAll(…): Promise<T[]> for objects of a given type
  • applyAllKeys(…): Promise<T[]> for objects with keys of a given type
  • apply(…): Promise<T> for single objects of a given type
  • applyKey(…): Promise<T> for single objects by a key of a given type

Thetype-argument defines the data-store in which the item should be contained. Using adepth you can definehow far the denormalization should be applied. A number means that all targets should be denormalized to the n-th level.null means that the field should be denormalized as far as possible. Note that circular dependencies currently willnot be detected. If you need different levels for various fields then use aDepth-object likee.g.{ foo: 3, bar: { x: 1, y: null }. This would denormalize up to 3 levels on obj.foo, 1 level on obj.bar.x andeverything on obj.bar.y.

Examples

See theexamples-project for detailed examples:


[8]ページ先頭

©2009-2025 Movatter.jp