@trycompai/db 1.0.9 → 1.1.0
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.
- package/README.md +9 -1
- package/dist/index.d.mts +2 -5
- package/dist/index.d.ts +2 -5
- package/dist/index.js +3 -9
- package/dist/index.mjs +1 -4
- package/package.json +1 -1
- package/scripts/setup-consumer.sh +6 -1
package/README.md
CHANGED
|
@@ -48,10 +48,18 @@ if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = db;
|
|
|
48
48
|
|
|
49
49
|
```typescript
|
|
50
50
|
import { db } from '@/lib/db';
|
|
51
|
-
import type { User, Organization } from '@trycompai/db';
|
|
51
|
+
import type { User, Organization, Prisma } from '@trycompai/db';
|
|
52
52
|
|
|
53
53
|
// Full type safety!
|
|
54
54
|
const users: User[] = await db.user.findMany();
|
|
55
|
+
|
|
56
|
+
// Create with type-safe input
|
|
57
|
+
const newUser = await db.user.create({
|
|
58
|
+
data: {
|
|
59
|
+
email: 'user@example.com',
|
|
60
|
+
name: 'John Doe',
|
|
61
|
+
} satisfies Prisma.UserCreateInput,
|
|
62
|
+
});
|
|
55
63
|
```
|
|
56
64
|
|
|
57
65
|
## Why This Approach?
|
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -3,10 +3,6 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
6
|
var __copyProps = (to, from, except, desc) => {
|
|
11
7
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
8
|
for (let key of __getOwnPropNames(from))
|
|
@@ -15,16 +11,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
11
|
}
|
|
16
12
|
return to;
|
|
17
13
|
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
16
|
|
|
20
17
|
// src/index.ts
|
|
21
18
|
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
DATABASE_URL: () => DATABASE_URL
|
|
24
|
-
});
|
|
25
19
|
module.exports = __toCommonJS(index_exports);
|
|
26
|
-
|
|
20
|
+
__reExport(index_exports, require("@prisma/client"), module.exports);
|
|
27
21
|
// Annotate the CommonJS export names for ESM import in node:
|
|
28
22
|
0 && (module.exports = {
|
|
29
|
-
|
|
23
|
+
...require("@prisma/client")
|
|
30
24
|
});
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -56,7 +56,12 @@ echo "
|
|
|
56
56
|
✨ Setup complete! You can now use the database:
|
|
57
57
|
|
|
58
58
|
import { db } from '@/lib/db';
|
|
59
|
-
import type { User, Organization } from '@trycompai/db';
|
|
59
|
+
import type { User, Organization, Prisma } from '@trycompai/db';
|
|
60
60
|
|
|
61
61
|
const users = await db.user.findMany();
|
|
62
|
+
|
|
63
|
+
// All Prisma types are available:
|
|
64
|
+
const newUser = await db.user.create({
|
|
65
|
+
data: {...} satisfies Prisma.UserCreateInput
|
|
66
|
+
});
|
|
62
67
|
"
|