totalknowledge / angular-launchpad

MIT License
2 stars 2 forks source link

Implement Schema(s) for web services, and auto-schema addition #40

Open totalknowledge opened 8 years ago

totalknowledge commented 8 years ago
api/v0/schema - returns entire schema as a schema

api/v0/schemas - returns list of schemas

api/v0/schemas/:id - returns one schema of :id

api/v0/collection/schema - Schema by collection

data: {
    id:":id",
    type: "schemas",
    schema: ":(locked|unlocked|auto)",
    collection: "collectionName",
    to-one: "singular"
    attributes: {
        attr1: {
            constraints: ":unique|set: ["", ""]|ObjectLoVwParentChildRelt",
            type: "number|integer|string|object|array|any",
            default: ":null|'sample'|#|object",
            required: ":true|false",
            indexed: ":true|false"
        }
    },
    relationships: {
        rel1: {
            <schema>,
            relationship: ":to-one|to-many",
            type: "pluralname"
            constraints:
            default:
            required,
            indexed:
            links: {
                self:
                collection:
            }
        }
    },
},
links: {
    self: ""
    collection:
},
meta: {
    <metainfo>
}
totalknowledge commented 8 years ago

So for example the following insert would auto create the appropriate schema.

{
    "type":"books",
    "attributes": {
        "title":"Bob",
        "publication_year":"1924"
    },
    "relationships": {
        "author":{
            "data": {
                "attributes": {
                    "name":"Bob Smith",
                },
                "type":"authors"
            }
        }
    }
}
{
    "data": {
        "id":"100",
        "type":"schemas",
        "schema":"auto",
        "collection":"books"
        "attributes":{
            "title": {
                "type":"any",
                "required":"false"
            },
            "publication_year": {
                "type":"any",
                "required":"false"
            }
        },
        "relationships": {
            "author": {
                "collection":"authors",
                "relationship":"to-one",
                "required":"false",
                "data":{
                    "id":"101",
                    "type":"schemas"
                "links": {
                    "self":"api/v0/authors/schema",
                    "collection":"api/v0/authors",
                    "relation":"api/v0/books/schema/author"
                }
            }
        }
    },
    "links":: {
        "self":"api/v0/schemas/100",
        "relation":"api/v0/books/schema",
        "collection":"api/v0/books",
    }
}
totalknowledge commented 8 years ago

Not implementing actual restrictions in the web services at this time, just the ability to auto create schemas and have schemas in general.