{"id":19714702,"url":"https://github.com/quavedev/definitions","last_synced_at":"2025-06-13T15:40:57.397Z","repository":{"id":47645045,"uuid":"264920009","full_name":"quavedev/definitions","owner":"quavedev","description":"Meteor package that provides a way for you to declare your models and enums","archived":false,"fork":false,"pushed_at":"2021-10-17T01:15:03.000Z","size":23,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-01-10T14:59:51.900Z","etag":null,"topics":["enum","meteor","meteor-package","model"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/quavedev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-18T11:35:00.000Z","updated_at":"2024-06-25T01:25:09.000Z","dependencies_parsed_at":"2022-09-23T13:31:46.763Z","dependency_job_id":null,"html_url":"https://github.com/quavedev/definitions","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quavedev%2Fdefinitions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quavedev%2Fdefinitions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quavedev%2Fdefinitions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quavedev%2Fdefinitions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quavedev","download_url":"https://codeload.github.com/quavedev/definitions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241035826,"owners_count":19898082,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["enum","meteor","meteor-package","model"],"created_at":"2024-11-11T22:35:00.273Z","updated_at":"2025-02-27T16:39:41.005Z","avatar_url":"https://github.com/quavedev.png","language":"JavaScript","readme":"# quave:definitions\n\n`quave:definitions` is a Meteor package that provides a way for you to declare your models and enums.\n\n## Why\n\nIt is desired to have a centralized way to declare schemas for your MongoDB collection and also your GraphQL schema.\n\nWe believe we are not reinventing the wheel in this package but what we are doing is like putting together the wheels in the vehicle :).\n\n## Installation\n\n```sh\nmeteor add quave:definitions\n```\n\n## Usage\n\nThe idea is to be as close as possible to a [SimpleSchema](https://github.com/aldeed/simple-schema-js) schema definition but also supporting additional properties when necessary for GraphQL and other necessities.\n\n### createModelDefinition\n\nYou provide a name for your model and fields, the fields is your schema definition.\n\nSee that you can use custom types from `meteor/quave:custom-type-*` like `DateTime` and also in combination with `createEnumDefinition` (see more below).\n\nWe have also special properties:\n- in the root\n  - pluralName: if your model has an irregular name\n- in the fields\n  - graphQLType: if you need to specify a type (scalar or special type) that has a different name in GraphQL than in MongoDB\n  - graphQLOptionalInput: if the input in GraphQL has a different optional value\n\n```javascript\nimport { createModelDefinition } from 'meteor/quave:definitions';\nimport { DateTimeType } from 'meteor/quave:custom-type-date-time/DateTimeType';\nimport { PlayerPositionDefinition } from './PlayerPositionEnum';\n\nexport const PlayerDefinition = createModelDefinition({\n  name: 'Player',\n  fields: {\n    name: {\n      type: String,\n    },\n    birthday: {\n      type: DateTimeType,\n      optional: true,\n    },\n    position: {\n      ...PlayerPositionDefinition.toSimpleSchemaField(),\n      optional: true,\n    },\n  },\n});\n\nexport const PlayerSchema = PlayerDefinition.toSimpleSchema();\n```\n\n### createEnumDefinition\n\nYou provide a name for your enum and options, the options are your static definitions in a limited domain.\n\nFunctions:\n- toSimpleSchemaField: transforms the enum definition into field properties, like allowedValues, type, etc\n- toEnum: returns the options adding the option key as a field called value to each item.\n\n```javascript\nimport { createEnumDefinition } from 'meteor/quave:definitions';\n\nexport const PlayerPositionDefinition = createEnumDefinition({\n  name: 'PlayerPosition',\n  options: {\n    GOLEIRO: {\n      name: 'Goleiro',\n    },\n    LATERAL_DIREITO: {\n      name: 'Lateral Direito',\n    },\n    LATERAL_ESQUERDO: {\n      name: 'Lateral Esquerdo',\n    },\n    ZAGUEIRO: {\n      name: 'Zagueiro',\n    },\n    VOLANTE: {\n      name: 'Volante',\n    },\n    MEIA: {\n      name: 'Meia',\n    },\n    ATACANTE: {\n      name: 'Atacante',\n    },\n    PONTA_DIREITA: {\n      name: 'Ponta Direita',\n    },\n    PONTA_ESQUERDA: {\n      name: 'Ponta Esquerda',\n    },\n  },\n});\n\nexport const PlayerPosition = PlayerPositionDefinition.toEnum();\n\n```\n\n### License\n\nMIT\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquavedev%2Fdefinitions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquavedev%2Fdefinitions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquavedev%2Fdefinitions/lists"}