///////////////////////////////////////////////// // // SQL SCHEMA // ///////////////////////////////////////////////// #Sql: { table_name?: string fields: [string]: #VarChar } #Storage: { sql: #Sql } #SQLField: { unique: bool | *false is_null: bool | *false default?: string nitro_type: #Types ... } #VarChar: #SQLField & { size: int | *255 nitro_type: #String } ///////////////////////////////////////////////// // // ENTITY SCHEMA // ///////////////////////////////////////////////// #Ref: { type: "$entity" name: string } #Scalar: { list: bool | *false go: { packages: [...{ name: string, }] type: string } ... } #String: #Scalar & { go: { type: "string" } } #StringList: #String & { list: true } #Types: #String | "number" | "bool" | #Ref | #Entity #Entity: { name: string fields: [string]: #Types | [...#Types] storage: #Storage graphql: #GraphQLType ref: #Ref } _entity: [string]: #Entity ///////////////////////////////////////////////// // // GRAPHQL SCHEMA // ///////////////////////////////////////////////// #GraphQLType: [string]: #Types | [...#Types] ///////////////////////////////////////////////// // // USER ENTITY // ///////////////////////////////////////////////// _entity: User: fields: { id: #String name: #String lol: #StringList car: _entity.Car.ref cars: _entity.Car.ref } _entity: User: graphql: { manufacturer: #String } _entity: User: storage: sql: { table_name: "users" fields: { surname: #VarChar } } ///////////////////////////////////////////////// // // CAR ENTITY // ///////////////////////////////////////////////// _entity: Car: fields: { id: #String brand: #String car: _entity.Car.ref } ///////////////////////////////////////////////// // // EXPORT // ///////////////////////////////////////////////// _entities: { for k, x in _entity { "\(k)": x & { fields: { for fk, s in x.storage.sql.fields { "\(fk)": s.nitro_type } for fk, s in x.graphql { "\(fk)": s } } } } } nitro: entities: _entities