@prmichaelsen/firebase-admin-sdk-v8 2.0.5 → 2.0.6

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/EXAMPLES.md CHANGED
@@ -50,16 +50,18 @@ await setDocument('users', 'user123', {
50
50
  import { addDocument } from 'firebase-admin-sdk-v8';
51
51
 
52
52
  // Auto-generate document ID
53
- const docId = await addDocument('posts', {
53
+ const docRef = await addDocument('posts', {
54
54
  title: 'Hello World',
55
55
  content: 'This is my first post',
56
56
  createdAt: new Date(),
57
57
  });
58
+ console.log('Created document:', docRef.id);
58
59
 
59
60
  // Or specify custom ID
60
- const customId = await addDocument('posts', {
61
+ const customDocRef = await addDocument('posts', {
61
62
  title: 'Custom ID Post',
62
63
  }, 'my-custom-id');
64
+ console.log('Created document:', customDocRef.id); // 'my-custom-id'
63
65
  ```
64
66
 
65
67
  ### Get Document
@@ -426,7 +428,7 @@ await setDocument('users', 'user123', {
426
428
  import { addDocument, FieldValue } from 'firebase-admin-sdk-v8';
427
429
 
428
430
  async function registerUser(email: string, name: string) {
429
- const userId = await addDocument('users', {
431
+ const docRef = await addDocument('users', {
430
432
  email,
431
433
  name,
432
434
  createdAt: FieldValue.serverTimestamp(),
@@ -435,7 +437,7 @@ async function registerUser(email: string, name: string) {
435
437
  roles: ['user'],
436
438
  });
437
439
 
438
- return userId;
440
+ return docRef.id;
439
441
  }
440
442
  ```
441
443
 
@@ -458,7 +460,7 @@ async function trackUserLogin(userId: string) {
458
460
  import { addDocument, updateDocument, FieldValue } from 'firebase-admin-sdk-v8';
459
461
 
460
462
  async function createPost(title: string, content: string, tags: string[]) {
461
- const postId = await addDocument('posts', {
463
+ const docRef = await addDocument('posts', {
462
464
  title,
463
465
  content,
464
466
  tags,
@@ -468,7 +470,7 @@ async function createPost(title: string, content: string, tags: string[]) {
468
470
  updatedAt: FieldValue.serverTimestamp(),
469
471
  });
470
472
 
471
- return postId;
473
+ return docRef.id;
472
474
  }
473
475
 
474
476
  async function addTagToPost(postId: string, tag: string) {
package/README.md CHANGED
@@ -169,13 +169,16 @@ await setDocument('users', 'user123', { age: 31, city: 'NYC' }, {
169
169
  });
170
170
  ```
171
171
 
172
- #### `addDocument(collectionPath, data, documentId?): Promise<string>`
172
+ #### `addDocument(collectionPath, data, documentId?): Promise<DocumentReference>`
173
173
 
174
- Add a document with auto-generated or custom ID.
174
+ Add a document with auto-generated or custom ID. Returns a DocumentReference with `id` and `path` properties.
175
175
 
176
176
  ```typescript
177
- const id = await addDocument('posts', { title: 'Hello' });
178
- const customId = await addDocument('posts', { title: 'Hi' }, 'custom-id');
177
+ const docRef = await addDocument('posts', { title: 'Hello' });
178
+ console.log('Created:', docRef.id); // Auto-generated ID
179
+
180
+ const customDocRef = await addDocument('posts', { title: 'Hi' }, 'custom-id');
181
+ console.log('Created:', customDocRef.id); // 'custom-id'
179
182
  ```
180
183
 
181
184
  #### `getDocument(collectionPath, documentId): Promise<DataObject | null>`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prmichaelsen/firebase-admin-sdk-v8",
3
- "version": "2.0.5",
3
+ "version": "2.0.6",
4
4
  "description": "Firebase Admin SDK for Cloudflare Workers and edge runtimes using REST APIs",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",