{"id":15295795,"url":"https://github.com/nexys-system/fetch-r","last_synced_at":"2025-04-13T18:22:57.708Z","repository":{"id":56808965,"uuid":"353826897","full_name":"nexys-system/fetch-r","owner":"nexys-system","description":"Typescript ORM and server for MySQL/PostgreSQL with GraphQL support","archived":false,"fork":false,"pushed_at":"2024-10-12T09:43:12.000Z","size":585,"stargazers_count":5,"open_issues_count":6,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-27T09:11:23.413Z","etag":null,"topics":["graphql","migration-tool","mysql","mysql-database","nexys","npm-package","orm","orm-framework","postgresql","typesafe","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@nexys/fetchr","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nexys-system.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-01T21:07:11.000Z","updated_at":"2024-10-12T09:43:16.000Z","dependencies_parsed_at":"2024-02-29T19:27:33.281Z","dependency_job_id":"8e852cd0-fdf5-4e19-ad51-22fd89c52086","html_url":"https://github.com/nexys-system/fetch-r","commit_stats":{"total_commits":293,"total_committers":3,"mean_commits":97.66666666666667,"dds":"0.23549488054607504","last_synced_commit":"d4544e5749c732b4d988a5e9a6d005800fb6718a"},"previous_names":[],"tags_count":92,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nexys-system%2Ffetch-r","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nexys-system%2Ffetch-r/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nexys-system%2Ffetch-r/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nexys-system%2Ffetch-r/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nexys-system","download_url":"https://codeload.github.com/nexys-system/fetch-r/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248759136,"owners_count":21157097,"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":["graphql","migration-tool","mysql","mysql-database","nexys","npm-package","orm","orm-framework","postgresql","typesafe","typescript"],"created_at":"2024-09-30T18:08:13.770Z","updated_at":"2025-04-13T18:22:57.685Z","avatar_url":"https://github.com/nexys-system.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fetch-R\n\n[![Build and Test Package](https://github.com/nexys-system/fetch-r/actions/workflows/build.yml/badge.svg)](https://github.com/nexys-system/fetch-r/actions/workflows/build.yml)\n[![Publish](https://github.com/nexys-system/fetch-r/actions/workflows/publish.yml/badge.svg)](https://github.com/nexys-system/fetch-r/actions/workflows/publish.yml)\n[![Deploy to docker](https://github.com/nexys-system/fetch-r/actions/workflows/deploy.yml/badge.svg)](https://github.com/nexys-system/fetch-r/actions/workflows/deploy.yml)\n[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][downloads-url]\n![Code style](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)\n\nTypescript ORM to connect to MySQL database\n\n_experimental support for PostgreSQL_\n\nTypescript port of [Scala version](https://github.com/nexys-system/fetch-r-scala)\n\n[npm-image]: https://img.shields.io/npm/v/@nexys/fetchr.svg\n[npm-url]: https://npmjs.org/package/@nexys/fetchr\n[downloads-image]: https://img.shields.io/npm/dm/@nexys/fetchr.svg\n[downloads-url]: https://npmjs.org/package/@nexys/fetchr.svg\n\n## Get started with the package\n\n### Install\n\n```\nyarn add @nexys/fetchr\n```\n\n### Use\n\n```\nimport FetchR from \"@nexys/fetchr\";\nimport { Database } from \"@nexys/fetchr/dist/database/type\";\nimport { Entity } from \"@nexys/fetchr/dist/type\";\n\nconst model: Entity[] = [\n  {\n    name: \"User\",\n    uuid: false,\n    fields: [\n      { name: \"firstName\", type: \"String\", optional: false },\n      { name: \"lastName\", type: \"String\", optional: false },\n      { name: \"email\", type: \"String\", optional: false },\n    ],\n  },\n];\n\nconst dbConfig: Database = {\n  username: \"\",\n  host: \"\",\n  password: \"\",\n  database: \"\",\n  port: 3306,\n};\n\nconst fetchr = new FetchR(dbConfig, model);\n\nfetchr.mutate({\n  User: {\n    insert: {\n      data: { firstName: \"john\", lastName: \"doe\", email: \"john@doe.com\" },\n    },\n  },\n});\n\n// get all users\nfetchr.query({ User: {} });\n\n// get all users' emails whose names are \"john\"\nfetchr.query({\n  User: { projection: { firstName: true }, filters: { firstName: \"John\" } },\n});\n```\n\n## Querying\n\nThere are 2 endpoints for querying: `/data` and `/mutate`. As their names suggests, the first one retrieves data and the second alters them. This is based on the same philosophy that was adopted by [graphql](https://graphql.org/learn/queries/).\n\n## Data\n\nThis is the query endpoint: `/query` (for legacy reason the endpoint `/data` is also available)\n\nThe querying language is very easy is straightforward and follows the structure defined [here](https://github.com/nexys-system/fetch-r/blob/master/src/service/type.ts#L65).\n\nNote that the endpoint always returns an object with the different entities queries as keys and the result in the form of an array as values.\n\n### Query Example\n\n- get a list of user from the entity `User`\n\n```\n{User: {}}\n```\n\n- get a list of user belonging to a particulart workspace\n\n```\n{User: {workspace:{id: workspaceId}}}\n```\n\n## Mutate\n\nAvailable through `/mutate`. The following actions are available\n\n- `insert`\n- `update`\n- `delete`\n\n## Model and Databases\n\nThe service supports multi models/databases\n\n### Models\n\n- Models can be set using `/model/set`\n- The strcuture is the one descrbied in [`/service/type`](https://github.com/nexys-system/fetch-r/blob/master/lib/service/type.ts#L30)\n- Models are stored in `/assets/models.json`\n\n### Databases\n\n- Models can be set using `/database/set`\n- The strcuture is the one descrbied in [`/service/database/type`](https://github.com/nexys-system/fetch-r/blob/master/src/lib/database/type.ts)\n- Databases are stored in `/assets/databases.json`\n\nWhen a query requiring a particular database is called, it will look for an associated connection pool. If none is found, it will create a new one based on the database record (if not found, an error is thrown) and store it in a `Map` object.\n\n### Migrations\n\nThe migration engines is largely inspired from flyway. An array of migrations can be passed; each having a unique combination of index and version (e.g. `2.1`, `2.2` etc). Migrations are stored in a separate table with their checksum values.\n\n### GraphQL\n\nGraphQL support is available. See https://github.com/nexys-system/server-boilerplate/blob/master/README.md#graphql-query-examples-tested-in-postman for more information\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnexys-system%2Ffetch-r","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnexys-system%2Ffetch-r","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnexys-system%2Ffetch-r/lists"}