prisma-datamodel
Advanced tools
Comparing version 1.31.0-beta.5 to 1.31.0-beta.6
@@ -11,3 +11,3 @@ export { DirectiveKeys } from './datamodel/directives'; | ||
export { default as AstTools } from './util/astTools'; | ||
export { capitalize, camelCase, plural, dedent } from './util/util'; | ||
export { capitalize, lowerCase, camelCase, plural, dedent } from './util/util'; | ||
export { toposort } from './util/sort'; | ||
@@ -14,0 +14,0 @@ export { TypeIdentifier, TypeIdentifiers } from './datamodel/scalar'; |
@@ -33,2 +33,3 @@ "use strict"; | ||
exports.capitalize = util_1.capitalize; | ||
exports.lowerCase = util_1.lowerCase; | ||
exports.camelCase = util_1.camelCase; | ||
@@ -35,0 +36,0 @@ exports.plural = util_1.plural; |
@@ -7,5 +7,10 @@ /** | ||
/** | ||
* Converts the first character of a word to lower case. | ||
* Converts the first character of a word to lower case | ||
* @param name | ||
*/ | ||
export declare function lowerCase(name: string): string; | ||
/** | ||
* Converts a string to camel case, respecting space, -, or _ as seperators. | ||
* @param name | ||
*/ | ||
export declare function camelCase(name: string): string; | ||
@@ -12,0 +17,0 @@ /** |
@@ -13,8 +13,21 @@ "use strict"; | ||
/** | ||
* Converts the first character of a word to lower case. | ||
* Converts the first character of a word to lower case | ||
* @param name | ||
*/ | ||
function camelCase(name) { | ||
function lowerCase(name) { | ||
return name.substring(0, 1).toLowerCase() + name.substring(1); | ||
} | ||
exports.lowerCase = lowerCase; | ||
/** | ||
* Converts a string to camel case, respecting space, -, or _ as seperators. | ||
* @param name | ||
*/ | ||
function camelCase(name) { | ||
var capitalized = name | ||
.split(/\s|-|_/) | ||
// We explicitely don't lowercase the second half - it might already be in camelcase. | ||
.map(function (word) { return word.substring(0, 1).toUpperCase() + word.substring(1); }) | ||
.join(''); | ||
return lowerCase(capitalized); | ||
} | ||
exports.camelCase = camelCase; | ||
@@ -21,0 +34,0 @@ /** |
{ | ||
"name": "prisma-datamodel", | ||
"version": "1.31.0-beta.5", | ||
"version": "1.31.0-beta.6", | ||
"description": "Transform prisma datamodel SDL into graphql-js SDL", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -7,7 +7,7 @@ # prisma-datamodel | ||
* 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 class`DefaultParser` | ||
* 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 `ISDL`structure, `toposort`to sort a datamodel in topological order. | ||
- 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 class`DefaultParser` | ||
- 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 `ISDL`structure, `toposort`to sort a datamodel in topological order. | ||
@@ -20,3 +20,3 @@ ### Different Database Types | ||
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. | ||
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. | ||
@@ -38,11 +38,17 @@ ### Modifying a Model | ||
// 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`) | ||
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 renderer = DefaultRenderer.create( | ||
DatabaseType.postgres, | ||
enableDatamodel1_1, | ||
) | ||
const renderedAsString = renderer.render(model) | ||
``` | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
208805
3419
52