0.0.3 • Published 2 years ago

onetable-jsonschema v0.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

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 } } });
0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago