Skip to content

RFC: enhancement over dgraph schema #117

@ghost

Description

Overview
Users should be able to define DGraph schema in object format. Defining schema in an object format will enable us to provide more validations to the schema in a clearer way like validation for each predicate, e.g.

UserSchema = new DgraphSchema({
    username: {
        type: 'String',
        index: true,
        immutable: true
    },

    password: {
        type: 'Password',
        min: 6,
        max: 26
    },
})

Motivation
A big motivation for such a feature comes from the package mongoose which a MongoDB client for javascript.

Action Items

  • Support DgraphSchema in an object format
  • Provide basic validation options such as:
    • immutable: [true | false]
    • min: [int] and max: [int]
    • unique: [true | false]
    • required: [true | false]
    • match: [new RegExp()]
    • default: [any] // default value for the predicate
    • lowercase: [true | false] // change the string to lowercase before saving into the DB
    • uppercase: [true | false] // change the string to uppercase before saving into the DB
  • return formatted error if provided data fails against the schema

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions