Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use RON files or macros to define schemas #49

Open
Figments opened this issue May 8, 2020 · 0 comments
Open

Use RON files or macros to define schemas #49

Figments opened this issue May 8, 2020 · 0 comments

Comments

@Figments
Copy link

Figments commented May 8, 2020

Much in the way Mongoose deals with schemas, I think it would be cool to see Wither handle document schemas in a way that's more natural with how documents are formatted within MongoDB itself, through either Diesel-style migrations using RON files in a migrations/[migration].ron kind of folder structure, or through macros.

An example RON file:

Users (
    _id: {
        type: String, // maybe as an enum of all supported types
    },
    username: {
        type: String,
        options: (
            // some miscellaneous options for this field
            required: true,
            unique: true,
        ),
    },
    // can also declare objects
    stats: {
        blogs: { type: Number, options: (required: false, default: 0)},
    },
    createdAt: {
        type: Date,
    },
)

(issue migrated from #47 so as not to clutter that one)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants