{"id":23069865,"url":"https://github.com/lafayettegabe/expo-shards","last_synced_at":"2025-04-03T10:13:38.810Z","repository":{"id":250359672,"uuid":"834243439","full_name":"lafayettegabe/expo-shards","owner":"lafayettegabe","description":"🔷 SQLite ORM for use with Expo in React Native. Features Declarative Data Modeling and an Auto-Generated, Type-Safe Query Builder.","archived":false,"fork":false,"pushed_at":"2024-07-26T19:11:05.000Z","size":141,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-08T23:27:12.120Z","etag":null,"topics":["expo","expo-go","javascript","mobile","orm","react","react-native","sqlite","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lafayettegabe.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":"2024-07-26T18:36:09.000Z","updated_at":"2024-11-04T17:30:35.000Z","dependencies_parsed_at":"2024-07-26T20:32:05.584Z","dependency_job_id":"2991c3e1-7ca4-470e-8e46-87a12e304bd5","html_url":"https://github.com/lafayettegabe/expo-shards","commit_stats":null,"previous_names":["lafayettegabe/expo-shards"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lafayettegabe%2Fexpo-shards","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lafayettegabe%2Fexpo-shards/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lafayettegabe%2Fexpo-shards/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lafayettegabe%2Fexpo-shards/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lafayettegabe","download_url":"https://codeload.github.com/lafayettegabe/expo-shards/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246981174,"owners_count":20863828,"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":["expo","expo-go","javascript","mobile","orm","react","react-native","sqlite","typescript"],"created_at":"2024-12-16T06:17:47.661Z","updated_at":"2025-04-03T10:13:38.768Z","avatar_url":"https://github.com/lafayettegabe.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- markdownlint-configure-file {\r\n  \"MD013\": {\r\n    \"code_blocks\": false,\r\n    \"tables\": false\r\n  },\r\n  \"MD033\": false,\r\n  \"MD041\": false\r\n} --\u003e\r\n\r\n\u003cdiv align=\"center\"\u003e\r\n\r\n# 🔷 Expo Shards\r\n\r\n### SQLite ORM for use with Expo in React Native\r\n\r\n[![npm][npm-badge]][npm]\r\n[![expo][expo-badge]][expo]\r\n[![react-native][react-native-badge]][react-native]\r\n[![sqlite][sqlite-badge]][sqlite]\r\n\r\n\u003c/div\u003e\r\n\r\n## Why?\r\n\r\nExpo Shards is an SQLite ORM designed specifically for use with Expo in React Native. It offers declarative data modeling and an auto-generated, type-safe query builder to simplify database interactions and improve development efficiency.\r\n\r\nA key feature of Expo Shards is its compatibility with Expo Go, which allows developers to test their applications instantly without needing to build native code. This feature is particularly useful during development, as it enables rapid iteration and testing of database interactions directly within Expo Go. Unlike many solutions that require native code modifications and builds, Expo Go provides a streamlined and efficient testing environment.\r\n\r\n## Project Status\r\n\r\n### Current State\r\n\r\n- **CLI**: The CLI is functional and supports the following commands:\r\n  - `npx expo-shards init`: Initializes a new project with an example `.shard` file.\r\n  - `npx expo-shards create \u003cdatabase-name\u003e`: Creates a new SQLite database with the specified name.\r\n  - `npx expo-shards generate`: Generates TypeScript interfaces and JSON schemas from the `.shard` file.\r\n\r\n- **Client**: The client code from a previous version is available as a base for future development but is not yet in use.\r\n\r\n### To Do\r\n\r\n- **Refactor Client Code**: Update and integrate the legacy client code to align with the latest project version and features.\r\n- **Enhance Documentation**: Improve documentation and examples to provide clearer instructions and better support for users.\r\n- **Implement Additional Features**: Develop new features and enhancements based on user feedback and project needs.\r\n\r\n## Using the CLI\r\n\r\nExpo Shards includes a CLI to help with initialization and management of your database schema. Here’s a quick overview of the available commands:\r\n\r\n### Initialization\r\n\r\nTo initialize a new project with Expo Shards, use:\r\n\r\n```sh\r\nnpx expo-shards init\r\n```\r\n\r\nThis command sets up a new project directory with an example `.shard` file, which serves as the declarative database schema.\r\n\r\n### Creating a New Database\r\n\r\nTo create a new SQLite database, you need to provide a name for the database. Use the following command:\r\n\r\n```sh\r\nnpx expo-shards create \u003cdatabase-name\u003e\r\n```\r\n\r\nReplace `\u003cdatabase-name\u003e` with the desired name for your database. This command will set up a new SQLite database with the specified name.\r\n\r\n### Generating Types and Schemas\r\n\r\nOnce your `.shard` file is configured, you can generate TypeScript interfaces and JSON schemas for your database with:\r\n\r\n```sh\r\nnpx expo-shards generate\r\n```\r\n\r\nThis command will create TypeScript interfaces in the `types` folder and JSON schemas needed to set up the SQLite database on the client side.\r\n\r\n## Example Workflow\r\n\r\n1. **Initialize** a new project:\r\n\r\n   ```sh\r\n   npx expo-shards init\r\n   ```\r\n\r\n2. **Create** a new database (replace `\u003cdatabase-name\u003e` with your chosen name):\r\n\r\n   ```sh\r\n   npx expo-shards create \u003cdatabase-name\u003e\r\n   ```\r\n\r\n3. **Generate** TypeScript interfaces and JSON schemas:\r\n\r\n   ```sh\r\n   npx expo-shards generate\r\n   ```\r\n\r\nBy following these steps, you'll have your Expo Shards setup and ready to use with a declarative schema and type-safe query builder.\r\n\r\n## Example `.shard` File\r\n\r\nThe `.shard` file defines your database schema declaratively. Here’s an example of what it might look like:\r\n\r\n```sh\r\ntable Users {\r\n  id        Int       @id  @default(autoincrement())\r\n  name      String\r\n  email     String    @unique\r\n  age       Int\r\n  created   DateTime  @default(now())\r\n  updated   DateTime  @updatedAt\r\n}\r\n\r\ntable GPS {\r\n  id        Int       @id  @default(autoincrement())\r\n  coordenada String\r\n}\r\n```\r\n\r\n## Generated TypeScript Interfaces\r\n\r\nWhen you run `npx expo-shards generate`, it will create TypeScript interfaces based on your schema. For the above `.shard` file, the generated interfaces would look like this:\r\n\r\n```ts\r\nexport interface Users {\r\n  id: number;\r\n  name: string;\r\n  email: string;\r\n  age: number;\r\n  created: Date;\r\n  updated: Date;\r\n}\r\n\r\nexport interface GPS {\r\n  id: number;\r\n  coordenada: string;\r\n}\r\n```\r\n\r\n## Generated JSON Schema\r\n\r\nThe `generate` command also produces JSON schemas that define the structure of your tables. For the given `.shard` file, the generated schemas would be:\r\n\r\n```json\r\n{\r\n  \"Users\": {\r\n    \"id\": {\r\n      \"type\": \"Int\",\r\n      \"primary\": true,\r\n      \"default\": \"autoincrement\"\r\n    },\r\n    \"name\": {\r\n      \"type\": \"String\"\r\n    },\r\n    \"email\": {\r\n      \"type\": \"String\",\r\n      \"unique\": true\r\n    },\r\n    \"age\": {\r\n      \"type\": \"Int\"\r\n    },\r\n    \"created\": {\r\n      \"type\": \"DateTime\",\r\n      \"default\": \"now\"\r\n    },\r\n    \"updated\": {\r\n      \"type\": \"DateTime\",\r\n      \"onUpdate\": true\r\n    }\r\n  },\r\n  \"GPS\": {\r\n    \"id\": {\r\n      \"type\": \"Int\",\r\n      \"primary\": true,\r\n      \"default\": \"autoincrement\"\r\n    },\r\n    \"coordenada\": {\r\n      \"type\": \"String\"\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n## Learn More\r\n\r\nTo learn more about Expo and React Native, take a look at the following resources:\r\n\r\n- [Expo Documentation](https://docs.expo.dev/) - Learn about Expo features and API.\r\n- [React Native Documentation](https://reactnative.dev/docs/getting-started) - Learn about React Native features and API.\r\n\r\nYou can also check out the [Expo GitHub repository](https://github.com/expo/expo) and the [React Native GitHub repository](https://github.com/facebook/react-native) for more information and to contribute.\r\n\r\n[expo]: https://expo.dev/\r\n[expo-badge]: https://img.shields.io/badge/expo-1C1C1C?style=for-the-badge\u0026logo=expo\u0026logoColor=white\r\n[react-native]: https://reactnative.dev/\r\n[react-native-badge]: https://img.shields.io/badge/react%20native-%2320232a.svg?style=for-the-badge\u0026logo=react\u0026logoColor=%2361DAFB\r\n[sqlite]: https://www.sqlite.org/\r\n[sqlite-badge]: https://img.shields.io/badge/sqlite-%23074059.svg?style=for-the-badge\u0026logo=sqlite\u0026logoColor=white\r\n[npm]: https://www.npmjs.com/package/expo-shards\r\n[npm-badge]: https://img.shields.io/npm/v/expo-shards?style=for-the-badge\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flafayettegabe%2Fexpo-shards","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flafayettegabe%2Fexpo-shards","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flafayettegabe%2Fexpo-shards/lists"}