prisma-datamodel
Transform prisma datamodel SDL into graphql-js SDL
Last updated 6 years ago by timsuchanek .
Apache-2.0 · Original npm · Tarball · package.json
$ npm install prisma-datamodel 
SYNC missed versions from official npm registry.

prisma-datamodel

The Prisma Datamodel package forms the foundation of all datamodel related tasks in the CLI.

Components

  • Data structures to represent datamodels in memory: ISDL, IGQLType, IGQLField. These data structures are documented inline. The data structures might be self referencing, and all operations in this library guarantee to keep the references valid.
  • Constants for known primitive types: TypeIdentifier, TypeIdentifiers
  • Classes to parse data models from strings into the internal format: Parser, with the factory classDefaultParser
  • Classes to render data models to strings, from the internal format: Renderer, with the factory class Default Renderer
  • Auxiliary functions: cloneSchema to safely clone an ISDLstructure, toposortto sort a datamodel in topological order.

Different Database Types

When creating a parser or renderer, a flag that indicates the database type has to be passed. The internal representation is guaranteed to be consistent between different databases. It is possible to parse a mongo schema and render a postgres schema without any transformations in between.

Datamodel V1 vs. V1.1

The parser is capable of parsing both datamodel formats, and even models with mixed directives from both standards. For rendering, a flag can be passed which indicates the datamodel format to follow.

Modifying a Model

The types ISDL, IGQLType and IGQLField are designed to allow convenient analysis and transformation. Most notably, they may contain circular references (for representing related types and indexes). Therefor, these types are mutable, and care has to be taken when modifying them, for example by cloning them using cloneSchema.

When adding or removing a type, it is important to also update all referring fields or indexes, otherwise other transformations or the rendering process might break.

Usage

Basic example:

const parser = DefaultParser.create(DatabaseType.mongo)
const model = parser.parse(datamodelAsString)

// Do something with the model
for (const type of model.types) {
  console.log(
    `${type.name} has ${type.fields.length} fields and ${
      type.indices.length
    } indexes`,
  )
}

const enableDatamodel1_1 = true
const renderer = DefaultRenderer.create(
  DatabaseType.postgres,
  enableDatamodel1_1,
)

const renderedAsString = renderer.render(model)

Current Tags

  • 1.36.0-alpha.11                                ...           alpha (5 years ago)
  • 1.35.0-beta                                ...           beta (5 years ago)
  • 1.34.12                                ...           latest (4 years ago)
  • 1.36.0-test.2                                ...           test (5 years ago)

345 Versions

  • 1.34.12                                ...           4 years ago
  • 1.34.11                                ...           4 years ago
  • 1.34.10                                ...           5 years ago
  • 1.34.8                                ...           5 years ago
  • 1.34.7                                ...           5 years ago
  • 1.34.6                                ...           5 years ago
  • 1.34.5                                ...           5 years ago
  • 1.34.3                                ...           5 years ago
  • 1.30.5                                ...           5 years ago
  • 1.34.2                                ...           5 years ago
  • 1.34.1                                ...           5 years ago
  • 1.36.0-alpha.11                                ...           5 years ago
  • 1.36.0-alpha.10                                ...           5 years ago
  • 1.36.0-alpha.9                                ...           5 years ago
  • 1.36.0-alpha.8                                ...           5 years ago
  • 1.36.0-alpha.7                                ...           5 years ago
  • 1.36.0-test.2                                ...           5 years ago
  • 1.36.0-test.1                                ...           5 years ago
  • 1.36.0-alpha.6                                ...           5 years ago
  • 1.36.0-alpha.5                                ...           5 years ago
  • 1.36.0-alpha.4                                ...           5 years ago
  • 1.36.0-alpha.3                                ...           5 years ago
  • 1.36.0-alpha.2                                ...           5 years ago
  • 1.36.0-alpha.1                                ...           5 years ago
  • 1.34.0                                ...           5 years ago
  • 1.35.0-beta                                ...           5 years ago
  • 1.34.0-beta.1                                ...           5 years ago
  • 1.35.0-alpha.2                                ...           5 years ago
  • 1.35.0-alpha.1                                ...           5 years ago
  • 1.33.0                                ...           6 years ago
  • 1.34.0-beta                                ...           6 years ago
  • 1.33.0-beta.4                                ...           6 years ago
  • 1.33.0-beta.3                                ...           6 years ago
  • 1.34.0-alpha.2                                ...           6 years ago
  • 1.34.0-alpha.1                                ...           6 years ago
  • 1.33.0-beta.2                                ...           6 years ago
  • 1.30.4                                ...           6 years ago
  • 1.32.2                                ...           6 years ago
  • 1.32.1                                ...           6 years ago
  • 1.30.3                                ...           6 years ago
  • 1.33.0-beta.1                                ...           6 years ago
  • 1.33.0-beta                                ...           6 years ago
  • 1.32.0                                ...           6 years ago
  • 1.32.0-beta.3                                ...           6 years ago
  • 1.32.0-beta.2                                ...           6 years ago
  • 1.33.0-alpha.3                                ...           6 years ago
  • 1.33.0-alpha.2                                ...           6 years ago
  • 1.32.0-beta.1                                ...           6 years ago
  • 1.31.2                                ...           6 years ago
  • 1.30.2                                ...           6 years ago
  • 1.33.0-alpha.1                                ...           6 years ago
  • 1.31.1                                ...           6 years ago
  • 1.32.0-beta                                ...           6 years ago
  • 1.31.0                                ...           6 years ago
  • 1.31.0-beta.6                                ...           6 years ago
  • 1.32.0-alpha.6                                ...           6 years ago
  • 1.32.0-alpha.5                                ...           6 years ago
  • 1.32.0-alpha.4                                ...           6 years ago
  • 1.32.0-alpha.3                                ...           6 years ago
  • 1.32.0-alpha.2                                ...           6 years ago
  • 1.31.0-beta.5                                ...           6 years ago
  • 1.30.1                                ...           6 years ago
  • 1.31.0-beta.4                                ...           6 years ago
  • 1.31.0-beta.3                                ...           6 years ago
  • 1.32.0-alpha.1                                ...           6 years ago
  • 1.31.0-beta.2                                ...           6 years ago
  • 1.31.0-beta.1                                ...           6 years ago
  • 1.31.0-beta                                ...           6 years ago
  • 1.30.0                                ...           6 years ago
  • 1.31.0-alpha.6                                ...           6 years ago
  • 1.31.0-alpha.5                                ...           6 years ago
  • 1.30.0-beta.11                                ...           6 years ago
  • 1.30.0-beta.10                                ...           6 years ago
  • 1.31.0-alpha.4                                ...           6 years ago
  • 1.30.0-beta.9                                ...           6 years ago
  • 1.30.0-beta.8                                ...           6 years ago
  • 1.30.0-beta.7                                ...           6 years ago
  • 1.30.0-beta.6                                ...           6 years ago
  • 1.30.0-beta.5                                ...           6 years ago
  • 1.30.0-beta.4                                ...           6 years ago
  • 1.29.2                                ...           6 years ago
  • 1.30.0-beta.3                                ...           6 years ago
  • 1.31.0-alpha.3                                ...           6 years ago
  • 1.31.0-alpha.2                                ...           6 years ago
  • 1.30.0-beta.2                                ...           6 years ago
  • 1.31.0-alpha.1                                ...           6 years ago
  • 1.29.1                                ...           6 years ago
  • 1.30.0-beta.1                                ...           6 years ago
  • 1.30.0-beta                                ...           6 years ago
  • 1.29.0                                ...           6 years ago
  • 1.29.0-beta.11                                ...           6 years ago
  • 1.29.0-beta.10                                ...           6 years ago
  • 1.28.5                                ...           6 years ago
  • 1.30.0-alpha.4                                ...           6 years ago
  • 1.30.0-alpha.3                                ...           6 years ago
  • 1.29.0-beta.9                                ...           6 years ago
  • 1.28.4                                ...           6 years ago
  • 1.30.0-alpha.2                                ...           6 years ago
  • 1.29.0-beta.8                                ...           6 years ago
  • 1.30.0-alpha.1                                ...           6 years ago
  • 1.29.0-beta.7                                ...           6 years ago
  • 1.29.0-beta.6                                ...           6 years ago
  • 1.29.0-beta.5                                ...           6 years ago
  • 1.29.0-beta.4                                ...           6 years ago
  • 1.29.0-beta.3                                ...           6 years ago
  • 1.29.0-beta.2                                ...           6 years ago
  • 1.29.0-beta.1                                ...           6 years ago
  • 1.28.3                                ...           6 years ago
  • 1.28.2                                ...           6 years ago
  • 1.28.1                                ...           6 years ago
  • 1.29.0-beta                                ...           6 years ago
  • 1.28.0                                ...           6 years ago
  • 1.28.0-beta.7                                ...           6 years ago
  • 1.28.0-beta.6                                ...           6 years ago
  • 1.29.0-alpha.8                                ...           6 years ago
  • 1.28.0-beta.5                                ...           6 years ago
  • 1.28.0-beta.4                                ...           6 years ago
  • 1.29.0-alpha.7                                ...           6 years ago
  • 1.28.0-beta.3                                ...           6 years ago
  • 1.28.0-beta.2                                ...           6 years ago
  • 1.28.0-beta.1                                ...           6 years ago
  • 1.27.4                                ...           6 years ago
  • 1.29.0-alpha.6                                ...           6 years ago
  • 1.27.3                                ...           6 years ago
  • 1.27.2                                ...           6 years ago
  • 1.29.0-alpha.5                                ...           6 years ago
  • 1.29.0-alpha.4                                ...           6 years ago
  • 1.29.0-alpha.3                                ...           6 years ago
  • 1.29.0-alpha.2                                ...           6 years ago
  • 1.27.1                                ...           6 years ago
  • 1.29.0-alpha.1                                ...           6 years ago
  • 1.28.0-beta                                ...           6 years ago
  • 1.27.0                                ...           6 years ago
  • 1.28.0-alpha.13                                ...           6 years ago
  • 1.28.0-alpha.12                                ...           6 years ago
  • 1.27.0-beta.14                                ...           6 years ago
  • 1.27.0-beta.13                                ...           6 years ago
  • 1.28.0-alpha.11                                ...           6 years ago
  • 1.27.0-beta.12                                ...           6 years ago
  • 1.27.0-beta.11                                ...           6 years ago
  • 1.28.0-alpha.10                                ...           6 years ago
  • 1.27.0-beta.10                                ...           6 years ago
  • 1.28.0-alpha.9                                ...           6 years ago
  • 1.26.6                                ...           6 years ago
  • 1.27.0-beta.9                                ...           6 years ago
  • 1.27.0-beta.8                                ...           6 years ago
  • 1.27.0-beta.7                                ...           6 years ago
  • 1.27.0-beta.6                                ...           6 years ago
  • 1.26.5                                ...           6 years ago
  • 1.27.0-beta.5                                ...           6 years ago
  • 1.28.0-alpha.8                                ...           6 years ago
  • 1.28.0-alpha.7                                ...           6 years ago
  • 1.28.0-alpha.6                                ...           6 years ago
  • 1.28.0-alpha.5                                ...           6 years ago
  • 1.28.0-alpha.4                                ...           6 years ago
  • 1.26.4                                ...           6 years ago
  • 1.28.0-alpha.3                                ...           6 years ago
  • 1.26.3                                ...           6 years ago
  • 1.28.0-alpha.2                                ...           6 years ago
  • 1.27.0-beta.4                                ...           6 years ago
  • 1.27.0-beta.3                                ...           6 years ago
  • 1.27.0-beta.2                                ...           6 years ago
  • 1.27.0-beta.1                                ...           6 years ago
  • 1.26.2                                ...           6 years ago
  • 1.28.0-alpha.1                                ...           6 years ago
  • 1.26.1                                ...           6 years ago
  • 1.27.0-alpha.32                                ...           6 years ago
  • 1.26.0-beta.19                                ...           6 years ago
  • 1.26.0-beta.18                                ...           6 years ago
  • 1.26.0-beta.17                                ...           6 years ago
  • 1.26.0-beta.16                                ...           6 years ago
  • 1.26.0-beta.15                                ...           6 years ago
  • 1.26.0-beta.14                                ...           6 years ago
  • 1.26.0-beta.13                                ...           6 years ago
  • 1.26.0-beta.12                                ...           6 years ago
  • 1.26.0-beta.11                                ...           6 years ago
  • 1.26.0-beta.10                                ...           6 years ago
  • 1.27.0-alpha.31                                ...           6 years ago
  • 1.27.0-alpha.30                                ...           6 years ago
  • 1.27.0-alpha.29                                ...           6 years ago
  • 1.26.0-beta.9                                ...           6 years ago
  • 1.26.0-beta.8                                ...           6 years ago
  • 1.27.0-alpha.28                                ...           6 years ago
  • 1.27.0-alpha.27                                ...           6 years ago
  • 1.27.0-alpha.26                                ...           6 years ago
  • 1.27.0-alpha.25                                ...           6 years ago
  • 1.27.0-beta                                ...           6 years ago
  • 1.26.0                                ...           6 years ago
  • 1.27.0-alpha.24                                ...           6 years ago
  • 1.26.0-beta.7                                ...           6 years ago
  • 1.26.0-beta.6                                ...           6 years ago
  • 1.27.0-alpha.23                                ...           6 years ago
  • 1.27.0-alpha.22                                ...           6 years ago
  • 1.26.0-beta.5                                ...           6 years ago
  • 1.26.0-beta.4                                ...           6 years ago
  • 1.27.0-alpha.21                                ...           6 years ago
  • 1.27.0-alpha.20                                ...           6 years ago
  • 1.27.0-alpha.19                                ...           6 years ago
  • 1.27.0-alpha.18                                ...           6 years ago
  • 1.27.0-alpha.17                                ...           6 years ago
  • 1.27.0-alpha.16                                ...           6 years ago
  • 1.27.0-alpha.15                                ...           6 years ago
  • 1.27.0-alpha.14                                ...           6 years ago
  • 1.27.0-alpha.13                                ...           6 years ago
  • 1.27.0-alpha.12                                ...           6 years ago
  • 1.25.7                                ...           6 years ago
  • 1.25.6                                ...           6 years ago
  • 1.25.5                                ...           6 years ago
  • 1.27.0-alpha.11                                ...           6 years ago
  • 1.27.0-alpha.10                                ...           6 years ago
  • 1.27.0-alpha.9                                ...           6 years ago
  • 1.27.0-alpha.8                                ...           6 years ago
  • 1.27.0-alpha.7                                ...           6 years ago
  • 1.26.0-beta.3                                ...           6 years ago
  • 1.25.4                                ...           6 years ago
  • 1.26.0-beta.2                                ...           6 years ago
  • 1.27.0-alpha.6                                ...           6 years ago
  • 1.27.0-alpha.5                                ...           6 years ago
  • 1.27.0-alpha.4                                ...           6 years ago
  • 1.27.0-alpha.3                                ...           6 years ago
  • 1.27.0-alpha.2                                ...           6 years ago
  • 1.25.3                                ...           6 years ago
  • 1.27.0-alpha.1                                ...           6 years ago
  • 1.25.2                                ...           6 years ago
  • 1.25.1                                ...           6 years ago
  • 1.26.0-beta.1                                ...           6 years ago
  • 1.25.0                                ...           6 years ago
  • 1.25.0-beta.33                                ...           6 years ago
  • 1.25.0-beta.32                                ...           6 years ago
  • 1.26.0-alpha.11                                ...           6 years ago
  • 1.26.0-alpha.10                                ...           6 years ago
  • 1.25.0-beta.31                                ...           6 years ago
  • 1.25.0-beta.30                                ...           6 years ago
  • 1.26.0-alpha.9                                ...           6 years ago
  • 1.26.0-alpha.8                                ...           6 years ago
  • 1.25.0-beta.29                                ...           6 years ago
  • 1.26.0-alpha.7                                ...           6 years ago
  • 1.25.0-beta.28                                ...           6 years ago
  • 1.26.0-alpha.6                                ...           6 years ago
  • 1.25.0-beta.27                                ...           6 years ago
  • 1.25.0-beta.26                                ...           6 years ago
  • 1.26.0-alpha.5                                ...           6 years ago
  • 1.25.0-beta.25                                ...           6 years ago
  • 1.25.0-beta.24                                ...           6 years ago
  • 1.26.0-alpha.4                                ...           6 years ago
  • 1.25.0-beta.23                                ...           6 years ago
  • 1.25.0-beta.22                                ...           6 years ago
  • 1.25.0-beta.21                                ...           6 years ago
  • 1.25.0-beta.20                                ...           6 years ago
  • 1.25.0-beta.19                                ...           6 years ago
  • 1.26.0-alpha.3                                ...           6 years ago
  • 1.25.0-beta.18                                ...           6 years ago
  • 1.26.0-alpha.2                                ...           6 years ago
  • 1.25.0-beta.17                                ...           6 years ago
  • 1.26.0-alpha.1                                ...           6 years ago
  • 1.25.0-beta.16                                ...           6 years ago
  • 1.25.0-beta.15                                ...           6 years ago
  • 1.25.0-beta.14                                ...           6 years ago
  • 1.25.0-beta.13                                ...           6 years ago
  • 1.25.0-beta.12                                ...           6 years ago
  • 1.25.0-beta.11                                ...           6 years ago
  • 1.25.0-beta.10                                ...           6 years ago
  • 1.25.0-beta.9                                ...           6 years ago
  • 1.25.0-beta.8                                ...           6 years ago
  • 1.25.0-beta.7                                ...           6 years ago
  • 1.25.0-beta.6                                ...           6 years ago
  • 1.25.0-beta.5                                ...           6 years ago
  • 1.25.0-beta.4                                ...           6 years ago
  • 1.25.0-beta.3                                ...           6 years ago
  • 1.25.0-beta.2                                ...           6 years ago
  • 1.25.0-beta.1                                ...           6 years ago
  • 1.24.0-beta.10                                ...           6 years ago
  • 1.24.0                                ...           6 years ago
  • 1.25.0-alpha.4                                ...           6 years ago
  • 1.24.0-beta.9                                ...           6 years ago
  • 1.24.0-beta.8                                ...           6 years ago
  • 1.25.0-alpha.3                                ...           6 years ago
  • 1.25.0-alpha.2                                ...           6 years ago
  • 1.23.4                                ...           6 years ago
  • 1.23.3                                ...           6 years ago
  • 1.24.0-beta.7                                ...           6 years ago
  • 1.24.0-beta.6                                ...           6 years ago
  • 1.24.0-beta.5                                ...           6 years ago
  • 1.25.0-alpha.1                                ...           6 years ago
  • 1.23.2                                ...           6 years ago
  • 1.24.0-beta.4                                ...           6 years ago
  • 1.24.0-beta.3                                ...           6 years ago
  • 1.24.0-beta.2                                ...           6 years ago
  • 1.23.1                                ...           6 years ago
  • 1.24.0-beta.1                                ...           6 years ago
  • 1.23.0                                ...           6 years ago
  • 1.23.0-beta.20                                ...           6 years ago
  • 1.24.0-alpha.5                                ...           6 years ago
  • 1.23.0-beta.19                                ...           6 years ago
  • 1.23.0-beta.18                                ...           6 years ago
  • 1.23.0-beta.17                                ...           6 years ago
  • 1.23.0-beta.16                                ...           6 years ago
  • 1.23.0-beta.15                                ...           6 years ago
  • 1.23.0-beta.14                                ...           6 years ago
  • 1.24.0-alpha.4                                ...           6 years ago
  • 1.23.0-beta.13                                ...           6 years ago
  • 1.24.0-alpha.3                                ...           6 years ago
  • 1.23.0-beta.12                                ...           6 years ago
  • 1.23.0-beta.11                                ...           6 years ago
  • 1.23.0-beta.10                                ...           6 years ago
  • 1.23.0-beta.9                                ...           6 years ago
  • 1.23.0-beta.8                                ...           6 years ago
  • 1.23.0-beta.7                                ...           6 years ago
  • 1.23.0-beta.6                                ...           6 years ago
  • 1.23.0-beta.5                                ...           6 years ago
  • 1.24.0-test.1                                ...           6 years ago
  • 1.24.0-alpha.2                                ...           6 years ago
  • 1.23.0-beta.4                                ...           6 years ago
  • 1.24.0-alpha.1                                ...           6 years ago
  • 1.23.0-beta.3                                ...           6 years ago
  • 1.23.0-beta.2                                ...           6 years ago
  • 1.23.0-beta.1                                ...           6 years ago
  • 1.22.0-beta.17                                ...           6 years ago
  • 1.23.0-alpha.191                                ...           6 years ago
  • 1.23.0-alpha.190                                ...           6 years ago
  • 1.23.0-alpha.189                                ...           6 years ago
  • 1.23.0-alpha.188                                ...           6 years ago
  • 1.23.0-alpha.187                                ...           6 years ago
  • 1.23.0-alpha.186                                ...           6 years ago
  • 1.23.0-alpha.185                                ...           6 years ago
  • 1.23.0-alpha.184                                ...           6 years ago
  • 1.23.0-alpha.183                                ...           6 years ago
  • 1.23.0-alpha.182                                ...           6 years ago
  • 1.23.0-alpha.181                                ...           6 years ago
  • 1.23.0-alpha.180                                ...           6 years ago
  • 1.23.0-alpha.179                                ...           6 years ago
  • 1.23.0-alpha.178                                ...           6 years ago
  • 1.23.0-alpha.177                                ...           6 years ago
  • 1.23.0-alpha.176                                ...           6 years ago
  • 1.23.0-alpha.175                                ...           6 years ago
  • 1.23.0-alpha.174                                ...           6 years ago
  • 1.23.0-alpha.173                                ...           6 years ago
  • 1.23.0-alpha.172                                ...           6 years ago
  • 1.23.0-alpha.171                                ...           6 years ago
  • 1.23.0-alpha.170                                ...           6 years ago
  • 1.23.0-alpha.169                                ...           6 years ago
  • 1.23.0-alpha.168                                ...           6 years ago
  • 1.23.0-alpha.167                                ...           6 years ago
  • 1.23.0-alpha.166                                ...           6 years ago
  • 1.23.0-alpha.1                                ...           6 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (7)

© 2010 - cnpmjs.org x YWFE | Home | YWFE