@prisma-idb/idb-client-generator 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +150 -4
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,8 +1,154 @@
1
- # Prisma-IDB
1
+ # Prisma IndexedDB Client Generator
2
2
 
3
- A package that allows you to query IndexedDB with your pre-existing `.prisma`
4
- schema files
3
+ This library is a **Prisma generator** that creates a client with a similar syntax and behavior to the Prisma Client but is designed to operate with **IndexedDB** for local storage. It allows developers to interact with IndexedDB using a familiar Prisma-like API.
4
+
5
+ ## ⚠️ Warning
6
+
7
+ This library is not fully ready yet. Check [issue #52](https://github.com/prisma-idb/idb-client-generator/issues/52) for the current list of implemented features.
8
+
9
+ ## Features
10
+
11
+ - Prisma-like syntax and API for IndexedDB.
12
+ - Supports CRUD operations with structured data.
13
+ - Integrates seamlessly with Prisma workflows.
14
+ - Generates a client tailored to your Prisma schema.
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ npm install @prisma-idb/idb-client-generator
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ ### 1. Add to Prisma Schema
25
+
26
+ Update your `prisma.schema` file to include the generator:
27
+
28
+ ```prisma
29
+ datasource db {
30
+ provider = "postgresql"
31
+ url = env("DATABASE_URL")
32
+ }
33
+
34
+ generator client {
35
+ provider = "prisma-client-js"
36
+ }
37
+
38
+ generator prismaIDB {
39
+ provider = "idb-client-generator"
40
+ output = "./prisma-idb"
41
+ }
42
+
43
+ model User {
44
+ id Int @id @default(autoincrement())
45
+ name String
46
+ email String @unique
47
+ }
48
+ ```
49
+
50
+ ### 2. Generate the Client
51
+
52
+ Run the Prisma client generation command:
53
+
54
+ ```bash
55
+ npx prisma generate
56
+ ```
57
+
58
+ This will generate a client in your project.
59
+
60
+ ### 3. Use the Client
61
+
62
+ Import the generated client and use it in your code:
63
+
64
+ ```typescript
65
+ import { PrismaIDBClient } from "./outputPath/prisma-idb-client";
66
+
67
+ async function main() {
68
+ const idbClient = await PrismaIDBClient.createClient();
69
+
70
+ await idbClient.user.create({
71
+ data: { name: "Alice", email: "alice@example.com" },
72
+ });
73
+
74
+ const users = await idbClient.user.findMany();
75
+ console.log(users);
76
+ }
77
+ ```
78
+
79
+ ## API
80
+
81
+ The API mimics Prisma Client's API for ease of use:
82
+
83
+ ### `create`
84
+
85
+ Insert a new record:
86
+
87
+ ```javascript
88
+ idbClient.modelName.create({
89
+ data: {
90
+ field: value,
91
+ },
92
+ });
93
+ ```
94
+
95
+ ### `findMany`
96
+
97
+ Retrieve all records:
98
+
99
+ ```javascript
100
+ idbClient.modelName.findMany();
101
+ ```
102
+
103
+ ### `findUnique`
104
+
105
+ Retrieve a single record by unique key:
106
+
107
+ ```javascript
108
+ idbClient.modelName.findUnique({
109
+ where: { key: value },
110
+ });
111
+ ```
112
+
113
+ ### `update`
114
+
115
+ Update a record:
116
+
117
+ ```javascript
118
+ idbClient.modelName.update({
119
+ where: { key: value },
120
+ data: { key: newValue },
121
+ });
122
+ ```
123
+
124
+ ### `delete`
125
+
126
+ Delete a record:
127
+
128
+ ```javascript
129
+ idbClient.modelName.delete({
130
+ where: { key: value },
131
+ });
132
+ ```
133
+
134
+ ## Development Notes
135
+
136
+ - **IndexedDB Dependency**: The client internally uses the `idb` library for IndexedDB operations.
137
+ - **Compatibility**: Ensure your environment supports IndexedDB (modern browsers).
138
+ - **Local-Only**: This is designed for local storage scenarios and does not support server-side databases.
139
+
140
+ ## Contributing
141
+
142
+ We welcome contributions! Please see our CONTRIBUTING.md for guidelines on how to contribute to this project.
143
+
144
+ ## Security
145
+
146
+ If you discover a security vulnerability, please follow our SECURITY.md guidelines on reporting issues responsibly.
5
147
 
6
148
  ## License
7
149
 
8
- GNU AGPL v3.0
150
+ This project is licensed under the GNU Affero General Public License v3.0. See the LICENSE file for more details.
151
+
152
+ ## Acknowledgements
153
+
154
+ Special thanks to the open-source community for their contributions to the tools and libraries used in this project.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prisma-idb/idb-client-generator",
3
3
  "description": "Generate types for idb from prisma schema",
4
- "version": "0.6.0",
4
+ "version": "0.6.1",
5
5
  "main": "dist/generator.js",
6
6
  "license": "MIT",
7
7
  "bin": {