Skip to content

Commit

Permalink
some better defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
rizen committed Apr 11, 2024
1 parent 914f4ec commit eabeb29
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions ving/generator/vingschema.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ export const ${camelCase(name)}Schema = {
owner: ['$userId', 'admin'],
props: [
...baseSchemaProps,
// name field
{
type: "string",
name: "name",
required: true,
unique: false,
length: 60,
default: '',
filterQuery: true,
db: (prop) => dbString(prop),
zod: (prop) => zodString(prop),
view: [],
edit: ['owner'],
},
// unique email field
{
type: "string",
Expand Down Expand Up @@ -83,7 +97,7 @@ export const ${camelCase(name)}Schema = {
default: 0,
filterRange: true,
db: (prop) => dbInt(prop),
zod: (prop) => zodNumber(prop).positive(),
zod: (prop) => zodNumber(prop).nonnegative(),
view: ['public'],
edit: [],
},
Expand Down Expand Up @@ -111,6 +125,17 @@ export const ${camelCase(name)}Schema = {
view: [],
edit: ['owner'],
},
// date field
{
type: "date",
name: "startedAt",
required: true,
filterRange: true,
default: () => new Date(),
db: (prop) => dbDateTime(prop),
view: ['public'],
edit: [],
},
// 1:N relationship - aka a relationship to my children
/* {
type: "virtual",
Expand Down Expand Up @@ -158,17 +183,6 @@ export const ${camelCase(name)}Schema = {
view: ['public'],
edit: ['owner'],
},
// date field
{
type: "date",
name: "startedAt",
required: true,
filterRange: true,
default: () => new Date(),
db: (prop) => dbDateTime(prop),
view: ['public'],
edit: [],
},
],
};`;

Expand Down

0 comments on commit eabeb29

Please sign in to comment.