Skip to content

FranckErnewein/onetable-jsonschema

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Onetable-jsonschema

convert JSON schema into OneTable Schema

Example

const { Table } = require("dynamodb-onetable");
const ontableJsonSchema = require("onetable-jsonschema");


// define a JSON schema
const UserSchema = {
  type: "object",
  properties: {
    name: { type: "string" },
    age: { type: "number" }
  },
  required: ["name"],
  additionalProperties: false
};

// convert it as OneTable schema
const User = ontableJsonSchema.default(UserSchema)

console.log(User); 
// output:
//{
//  name: { type: [Function: String], required: true },
//  age: { type: [Function: Number] }
//}


// init OneTable
new Table({ schema: { models: { User } } });

About

convert JSON schema into OneTable Schema

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published