{"id":15568748,"url":"https://github.com/nikolasburk/data-browser-demo","last_synced_at":"2025-09-04T18:10:41.125Z","repository":{"id":82369612,"uuid":"362032584","full_name":"nikolasburk/data-browser-demo","owner":"nikolasburk","description":null,"archived":false,"fork":false,"pushed_at":"2021-04-27T08:11:08.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T06:11:18.338Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/nikolasburk.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-27T08:10:59.000Z","updated_at":"2021-04-27T08:29:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"6b97882c-9225-4523-b27a-f56f82f0617c","html_url":"https://github.com/nikolasburk/data-browser-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nikolasburk/data-browser-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikolasburk%2Fdata-browser-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikolasburk%2Fdata-browser-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikolasburk%2Fdata-browser-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikolasburk%2Fdata-browser-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nikolasburk","download_url":"https://codeload.github.com/nikolasburk/data-browser-demo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikolasburk%2Fdata-browser-demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273650074,"owners_count":25143778,"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","status":"online","status_checked_at":"2025-09-04T02:00:08.968Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-10-02T17:20:41.424Z","updated_at":"2025-09-04T18:10:41.100Z","avatar_url":"https://github.com/nikolasburk.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple TypeScript Script Example\n\nThis example shows how to use [Prisma Client](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client) in a **simple TypeScript script** to read and write data in a SQLite database. You can find the database file with some dummy data at [`./prisma/dev.db`](./prisma/dev.db).\n\n## Getting started\n\n### 1. Download example and install dependencies\n\nDownload this example:\n\n```\ncurl https://codeload.github.com/prisma/prisma-examples/tar.gz/latest | tar -xz --strip=2 prisma-examples-latest/typescript/script\n```\n\nInstall npm dependencies:\n\n```\ncd script\nnpm install\n```\n\n\u003cdetails\u003e\u003csummary\u003e\u003cstrong\u003eAlternative:\u003c/strong\u003e Clone the entire repo\u003c/summary\u003e\n\nClone this repository:\n\n```\ngit clone git@github.com:prisma/prisma-examples.git --depth=1\n```\n\nInstall npm dependencies:\n\n```\ncd prisma-examples/typescript/script\nnpm install\n```\n\n\u003c/details\u003e\n\n### 2. Create the database\n\nRun the following command to create your SQLite database file. This also creates the `User` and `Post` tables that are defined in [`prisma/schema.prisma`](./prisma/schema.prisma):\n\n```\nnpx prisma migrate dev --name init\n```\n\n### 3. Run the script\n\nExecute the script with this command: \n\n```\nnpm run dev\n```\n\n## Evolving the app\n\nEvolving the application typically requires two steps:\n\n1. Migrate your database using Prisma Migrate\n1. Update your application code\n\nFor the following example scenario, assume you want to add a \"profile\" feature to the app where users can create a profile and write a short bio about themselves.\n\n### 1. Migrate your database using Prisma Migrate\n\nThe first step is to add a new table, e.g. called `Profile`, to the database. You can do this by adding a new model to your [Prisma schema file](./prisma/schema.prisma) file and then running a migration afterwards:\n\n```diff\n// schema.prisma\n\nmodel Post {\n  id        Int     @default(autoincrement()) @id\n  title     String\n  content   String?\n  published Boolean @default(false)\n  author    User?   @relation(fields: [authorId], references: [id])\n  authorId  Int\n}\n\nmodel User {\n  id      Int      @default(autoincrement()) @id \n  name    String? \n  email   String   @unique\n  posts   Post[]\n+ profile Profile?\n}\n\n+model Profile {\n+  id     Int     @default(autoincrement()) @id\n+  bio    String?\n+  userId Int     @unique\n+  user   User    @relation(fields: [userId], references: [id])\n+}\n```\n\nOnce you've updated your data model, you can execute the changes against your database with the following command:\n\n```\nnpx prisma migrate dev\n```\n\n### 2. Update your application code\n\nYou can now use your `PrismaClient` instance to perform operations against the new `Profile` table. Here are some examples:\n\n#### Create a new profile for an existing user\n\n```ts\nconst profile = await prisma.profile.create({\n  data: {\n    bio: \"Hello World\",\n    user: {\n      connect: { email: \"alice@prisma.io\" },\n    },\n  },\n});\n```\n\n#### Create a new user with a new profile\n\n```ts\nconst user = await prisma.user.create({\n  data: {\n    email: \"john@prisma.io\",\n    name: \"John\",\n    profile: {\n      create: {\n        bio: \"Hello World\",\n      },\n    },\n  },\n});\n```\n\n#### Update the profile of an existing user\n\n```ts\nconst userWithUpdatedProfile = await prisma.user.update({\n  where: { email: \"alice@prisma.io\" },\n  data: {\n    profile: {\n      update: {\n        bio: \"Hello Friends\",\n      },\n    },\n  },\n});\n```\n\n\n## Switch to another database (e.g. PostgreSQL, MySQL, SQL Server)\n\nIf you want to try this example with another database than SQLite, you can adjust the the database connection in [`prisma/schema.prisma`](./prisma/schema.prisma) by reconfiguring the `datasource` block. \n\nLearn more about the different connection configurations in the [docs](https://www.prisma.io/docs/reference/database-reference/connection-urls).\n\n\u003cdetails\u003e\u003csummary\u003eExpand for an overview of example configurations with different databases\u003c/summary\u003e\n\n### PostgreSQL\n\nFor PostgreSQL, the connection URL has the following structure:\n\n```prisma\ndatasource db {\n  provider = \"postgresql\"\n  url      = \"postgresql://USER:PASSWORD@HOST:PORT/DATABASE?schema=SCHEMA\"\n}\n```\n\nHere is an example connection string with a local PostgreSQL database:\n\n```prisma\ndatasource db {\n  provider = \"postgresql\"\n  url      = \"postgresql://janedoe:mypassword@localhost:5432/notesapi?schema=public\"\n}\n```\n\n### MySQL\n\nFor MySQL, the connection URL has the following structure:\n\n```prisma\ndatasource db {\n  provider = \"mysql\"\n  url      = \"mysql://USER:PASSWORD@HOST:PORT/DATABASE\"\n}\n```\n\nHere is an example connection string with a local MySQL database:\n\n```prisma\ndatasource db {\n  provider = \"mysql\"\n  url      = \"mysql://janedoe:mypassword@localhost:3306/notesapi\"\n}\n```\n\n### Microsoft SQL Server (Preview)\n\nHere is an example connection string with a local Microsoft SQL Server database:\n\n```prisma\ndatasource db {\n  provider = \"sqlserver\"\n  url      = \"sqlserver://localhost:1433;initial catalog=sample;user=sa;password=mypassword;\"\n}\n```\n\nBecause SQL Server is currently in [Preview](https://www.prisma.io/docs/about/releases#preview), you need to specify the `previewFeatures` on your `generator` block:\n\n```prisma\ngenerator client {\n  provider        = \"prisma-client-js\"\n  previewFeatures = [\"microsoftSqlServer\"]\n}\n```\n\n\u003c/details\u003e\n\n## Next steps\n\n- Check out the [Prisma docs](https://www.prisma.io/docs)\n- Share your feedback in the [`prisma2`](https://prisma.slack.com/messages/CKQTGR6T0/) channel on the [Prisma Slack](https://slack.prisma.io/)\n- Create issues and ask questions on [GitHub](https://github.com/prisma/prisma/)\n- Watch our biweekly \"What's new in Prisma\" livestreams on [Youtube](https://www.youtube.com/channel/UCptAHlN1gdwD89tFM3ENb6w)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikolasburk%2Fdata-browser-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnikolasburk%2Fdata-browser-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikolasburk%2Fdata-browser-demo/lists"}