@ginger.io/beyonce
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -30,2 +30,3 @@ "use strict"; | ||
const generateTables_1 = require("./generateTables"); | ||
const generateModelHelpers_1 = require("./generateModelHelpers"); | ||
function generateModels(yamlData) { | ||
@@ -42,2 +43,3 @@ const config = parseYaml(yamlData); | ||
modelInterfaces.imports.forEach(_ => imports.add(_)); | ||
const modelHelpers = generateModelHelpers_1.generateModelHelpers(models); | ||
const code = ` | ||
@@ -50,2 +52,4 @@ ${Array.from(imports).join("\n")} | ||
${modelHelpers} | ||
${tables} | ||
@@ -52,0 +56,0 @@ `; |
{ | ||
"name": "@ginger.io/beyonce", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "Type-safe DynamoDB query builder for TypeScript. Designed with single-table architecture in mind.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -85,2 +85,3 @@ # Beyonce | ||
Author, | ||
author, | ||
Book, | ||
@@ -103,7 +104,7 @@ ModelType, | ||
```TypeScript | ||
const authorModel: Author = { | ||
// Beyonce generates helper methods to create model objects for you | ||
const authorModel = author({ | ||
id: "1", | ||
name: "Jane Austin", | ||
model: ModelType.Author | ||
} | ||
name: "Jane Austin" | ||
}) | ||
@@ -110,0 +111,0 @@ await db.put( |
@@ -8,2 +8,3 @@ import yaml from "js-yaml" | ||
import { ModelDefinitions, Table } from "./types" | ||
import { generateModelHelpers } from "./generateModelHelpers" | ||
@@ -25,2 +26,4 @@ export function generateModels(yamlData: string): string { | ||
const modelHelpers = generateModelHelpers(models) | ||
const code = ` | ||
@@ -33,2 +36,4 @@ ${Array.from(imports).join("\n")} | ||
${modelHelpers} | ||
${tables} | ||
@@ -35,0 +40,0 @@ ` |
@@ -30,2 +30,9 @@ import { generateModels } from "../../main/codegen/generateModels" | ||
export function author(fields: Omit<Author, "model">): Author { | ||
return { | ||
...fields, | ||
model: ModelType.Author | ||
} | ||
} | ||
export const LibraryTable = { | ||
@@ -87,2 +94,16 @@ name: "Library", | ||
export function author(fields: Omit<Author, "model">): Author { | ||
return { | ||
...fields, | ||
model: ModelType.Author | ||
} | ||
} | ||
export function book(fields: Omit<Book, "model">): Book { | ||
return { | ||
...fields, | ||
model: ModelType.Book | ||
} | ||
} | ||
export const LibraryTable = { | ||
@@ -89,0 +110,0 @@ name: "Library", |
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
75355
72
1345
190