@goatlab/fluent-firebase 0.8.0 → 0.8.2
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 +27 -5
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@ pnpm add @goatlab/fluent-firebase
|
|
|
16
16
|
|
|
17
17
|
```typescript
|
|
18
18
|
import { FirebaseInit, FirebaseConnector } from '@goatlab/fluent-firebase'
|
|
19
|
+
import { Entity, ObjectType, f } from '@goatlab/fluent'
|
|
19
20
|
import { z } from 'zod'
|
|
20
21
|
|
|
21
22
|
// Initialize Firebase
|
|
@@ -25,19 +26,36 @@ FirebaseInit({
|
|
|
25
26
|
emulator: false // set to true for local development
|
|
26
27
|
})
|
|
27
28
|
|
|
29
|
+
// Define your entity
|
|
30
|
+
@Entity('users')
|
|
31
|
+
@ObjectType()
|
|
32
|
+
export class UserEntity {
|
|
33
|
+
@f.Column()
|
|
34
|
+
id: string
|
|
35
|
+
|
|
36
|
+
@f.Column()
|
|
37
|
+
name: string
|
|
38
|
+
|
|
39
|
+
@f.Column()
|
|
40
|
+
email: string
|
|
41
|
+
|
|
42
|
+
@f.Column()
|
|
43
|
+
created: Date
|
|
44
|
+
}
|
|
45
|
+
|
|
28
46
|
// Define your schema
|
|
29
47
|
const UserSchema = z.object({
|
|
30
|
-
id: z.string(),
|
|
48
|
+
id: z.string().optional(),
|
|
31
49
|
name: z.string(),
|
|
32
50
|
email: z.string().email(),
|
|
33
|
-
created: z.date()
|
|
51
|
+
created: z.date().optional()
|
|
34
52
|
})
|
|
35
53
|
|
|
36
54
|
// Create a repository
|
|
37
|
-
class UserRepository extends FirebaseConnector<
|
|
55
|
+
class UserRepository extends FirebaseConnector<UserEntity> {
|
|
38
56
|
constructor() {
|
|
39
57
|
super({
|
|
40
|
-
entity: UserEntity,
|
|
58
|
+
entity: UserEntity,
|
|
41
59
|
inputSchema: UserSchema,
|
|
42
60
|
outputSchema: UserSchema // optional, defaults to inputSchema
|
|
43
61
|
})
|
|
@@ -75,4 +93,8 @@ await userRepo.deleteById(user.id)
|
|
|
75
93
|
- **Batch operations** for efficient bulk inserts and updates
|
|
76
94
|
- **Relations support** for loading related data
|
|
77
95
|
- **Firebase Emulator support** for local development and testing
|
|
78
|
-
- **Raw access** to Firebase Admin SDK when needed
|
|
96
|
+
- **Raw access** to Firebase Admin SDK when needed
|
|
97
|
+
|
|
98
|
+
## License
|
|
99
|
+
|
|
100
|
+
MIT
|