# @personal-companion/prisma-service

> Prisma service for personal companion server

Latest version **1.0.0** (published 2023-09-01) · ISC license · 0 weekly downloads

## Install

```sh
npm install @personal-companion/prisma-service
pnpm add @personal-companion/prisma-service
yarn add @personal-companion/prisma-service
bun add @personal-companion/prisma-service
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2023-09-01 |
| First published | 2023-09-01 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 14 |
| Unpacked size | 34.8 KB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| Author | @personal-companion/jdelgad8 |
| Maintainers | jdelgad8 |
| Keywords | companion, personal, prisma |

## Links

- npm: https://www.npmjs.com/package/@personal-companion/prisma-service
- Repository: https://github.com/personal-companion/prisma-service
- Homepage: https://github.com/personal-companion/prisma-service#readme
- Issues: https://github.com/personal-companion/prisma-service/issues
- npm.io page: https://npm.io/package/@personal-companion/prisma-service

## Dependencies (14)

- [rxjs](https://npm.io/package/rxjs.md) ^7.8.1
- [rimraf](https://npm.io/package/rimraf.md) ^5.0.1
- [graphql](https://npm.io/package/graphql.md) ^16.8.0
- [@nestjs/core](https://npm.io/package/@nestjs/core.md) ^10.2.2
- [graphql-tools](https://npm.io/package/graphql-tools.md) ^9.0.0
- [@apollo/server](https://npm.io/package/@apollo/server.md) ^4.9.2
- [@nestjs/apollo](https://npm.io/package/@nestjs/apollo.md) ^12.0.7
- [@nestjs/common](https://npm.io/package/@nestjs/common.md) ^10.2.2
- [@prisma/client](https://npm.io/package/@prisma/client.md) ^5.2.0
- [@nestjs/graphql](https://npm.io/package/@nestjs/graphql.md) ^12.0.8
- [class-validator](https://npm.io/package/class-validator.md) ^0.14.0
- [reflect-metadata](https://npm.io/package/reflect-metadata.md) ^0.1.13
- [@nestjs/platform-express](https://npm.io/package/@nestjs/platform-express.md) ^10.2.2
- [@prisma/extension-accelerate](https://npm.io/package/@prisma/extension-accelerate.md) ^0.6.2

## Alternatives

- [@oh-my-pi/pi-natives](https://npm.io/package/@oh-my-pi/pi-natives.md) — 51.8K weekly downloads
- [@capgo/capacitor-light-sensor](https://npm.io/package/@capgo/capacitor-light-sensor.md) — 3.0K weekly downloads
- [@heyhuynhgiabuu/pi-diff](https://npm.io/package/@heyhuynhgiabuu/pi-diff.md) — 492 weekly downloads
- [@lotsa/verdant-lang-asm](https://npm.io/package/@lotsa/verdant-lang-asm.md) — 38 weekly downloads
- [new-era-syntax](https://npm.io/package/new-era-syntax.md) — 20 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2023-09-01

## README

# prisma-service

Prisma service for personal companion

# GraphQL Server Example with NestJS (SDL-first)

This example shows how to implement an **GraphQL server (SDL-first) with TypeScript** with the following stack:

- [**NestJS**](https://docs.nestjs.com/graphql/quick-start): Web framework for building scalable server-side applications
- [**graphql-tools**](https://www.apollographql.com/docs/graphql-tools/): A tool for combining resolvers and type-definitions into an executable schema
- [**Prisma Client**](https://www.prisma.io/docs/concepts/components/prisma-client): Databases access (ORM)
- [**Prisma Migrate**](https://www.prisma.io/docs/concepts/components/prisma-migrate): Database migrations

## Getting started

### 1. Install dependencies

Clone repository:

```
git clone https://github.com/personal-companion/prisma-service.git
```

Install npm dependencies:

```
cd prisma-service
npm install
```

### 2. Create and seed the database

```
npx prisma migrate dev --name init
```

When `npx prisma migrate dev` is executed against a newly created database, seeding is also triggered. The seed file in [`prisma/seed.ts`](./prisma/seed.ts) will be executed and your database will be populated with the sample data.

### 2. Start the GraphQL server

Launch your GraphQL server with this command:

```
npm run dev
```

Navigate to [http://localhost:710/graphql](http://localhost:710/graphql) in your browser to explore the API of your GraphQL server in a [GraphQL Playground](https://github.com/prisma/graphql-playground).

## Using the GraphQL API

The schema that specifies the API operations of your GraphQL server is defined in [`./schema.graphql`](./schema.graphql). Below are a number of operations that you can send to the API using the GraphQL Playground.

### 1. Migrate your database using Prisma Migrate

The 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:

Once you've updated your data model, you can execute the changes against your database with the following command:

```
npx prisma migrate dev --name [DESCRIPTION]
```

This adds another migration to the `prisma/migrations` directory.

### 2. Update your application code

You can now use your `PrismaClient` instance to perform operations against the new `Profile table.
Those operations can be used to implement queries and mutations in the GraphQL API

## Switch to another database (e.g. PostgreSQL, MySQL, SQL Server, MongoDB)

If 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.

Learn more about the different connection configurations in the [docs](https://www.prisma.io/docs/reference/database-reference/connection-urls).

<details><summary>Expand for an overview of example configurations with different databases</summary>

### PostgreSQL

For PostgreSQL, the connection URL has the following structure:

```prisma
datasource db {
  provider = "postgresql"
  url      = "postgresql://USER:PASSWORD@HOST:PORT/DATABASE?schema=SCHEMA"
}
```

Here is an example connection string with a local PostgreSQL database:

```prisma
datasource db {
  provider = "postgresql"
  url      = "postgresql://janedoe:mypassword@localhost:5432/notesapi?schema=public"
}
```

### MySQL

For MySQL, the connection URL has the following structure:

```prisma
datasource db {
  provider = "mysql"
  url      = "mysql://USER:PASSWORD@HOST:PORT/DATABASE"
}
```

Here is an example connection string with a local MySQL database:

```prisma
datasource db {
  provider = "mysql"
  url      = "mysql://janedoe:mypassword@localhost:3306/notesapi"
}
```

### Microsoft SQL Server

Here is an example connection string with a local Microsoft SQL Server database:

```prisma
datasource db {
  provider = "sqlserver"
  url      = "sqlserver://localhost:1433;initial catalog=sample;user=sa;password=mypassword;"
}
```

### MongoDB

Here is an example connection string with a local MongoDB database:

```prisma
datasource db {
  provider = "mongodb"
  url      = "mongodb://USERNAME:PASSWORD@HOST/DATABASE?authSource=admin&retryWrites=true&w=majority"
}
```

</details>

## Next steps

- Check out the [Prisma docs](https://www.prisma.io/docs)
- Share your feedback in the [`#product-wishlist`](https://prisma.slack.com/messages/CKQTGR6T0/) channel on the [Prisma Slack](https://slack.prisma.io/)
- Create issues and ask questions on [GitHub](https://github.com/prisma/prisma/)
- Watch our biweekly "What's new in Prisma" livestreams on [Youtube](https://www.youtube.com/channel/UCptAHlN1gdwD89tFM3ENb6w)

---
_Source: https://npm.io/package/@personal-companion/prisma-service · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
