DemocracyOS / core

1 stars 1 forks source link

Create DocumentType Model and DB-APIs #18

Closed guillecro closed 6 years ago

guillecro commented 6 years ago
param Type options
name String required
icon String required
description String required
fields Object required

For now we will be making the field fields an Object field for now, for saving the JSON of a schema.

{
  "$id": "https://example.com/person.schema.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Person",
  "type": "object",
  "properties": {
    "firstName": {
      "type": "string",
      "description": "The person's first name."
    },
    "lastName": {
      "type": "string",
      "description": "The person's last name."
    },
    "age": {
      "description": "Age in years which must be equal to or greater than zero.",
      "type": "integer",
      "minimum": 0
    }
  }
}

Also, every update of this will mean in a new version of this document type So we will have to use the plugin for versioning. Here is the repo. Install it as a dependence. https://github.com/saintedlama/mongoose-version

Also we need to create the following db-api methods for DocumentType

Method Description Returns
DocumentType.create() Creates the document type The created documentType
DocumentType.update( {id, documentType } ) Updates a document type The updated documentType
DocumentType.get(id) Gets the document type The documentType with the id
DocumentType.list(id) Lists the document type A list with the paginator fields and a list of document types
DocumentType.delete(id) Deletes the document type Nothing