JSON Schema

We provide Inkdrop data model definitions in json-schema and flowtype. The source code is hosted on GitHub.


Json Schema

You can use schemas by importing inkdrop-model module like so:

import { NoteSchema, BookSchema, TagSchema, FileSchema } from 'inkdrop-model'

Validating data

You can validate data with json schemas. Below example uses ajv as a validator:

import { NoteSchema } from 'inkdrop-model'
import Ajv from 'ajv'
const ajv = new Ajv()
const validate = ajv.compile(NoteSchema)

const data = {
  _id: 'note:BkgOZZUJzf',
  title: 'link',
  doctype: 'markdown',
  updatedAt: 1513330812556,
  createdAt: 1513214207639,
  tags: [],
  status: 'none',
  share: 'private',
  body: 'markdown note body',
  bookId: 'book:first',
  _rev: '38-636e505958d24f9c21614d95ea03b5a1'
const valid = validate(data)
console.log(valid) // => true

Can you help us improve these docs?

The source of these docs is here on GitHub. If you see a way these docs can be improved, please fork us!