Skip to content

Commit

Permalink
update: release v2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
POPPIN-FUMI committed Oct 24, 2023
1 parent 3c81755 commit d9bc5d1
Show file tree
Hide file tree
Showing 41 changed files with 357 additions and 33 deletions.
2 changes: 1 addition & 1 deletion dist/cjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@skeet-framework/firestore",
"version": "2.3.3",
"version": "2.4.0",
"description": "Skeet Framework Plugin - Firestore",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
Expand Down
1 change: 1 addition & 0 deletions dist/cjs/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export {
queryCollectionItems as query,
updateCollectionItem as update,
deleteCollectionItem as remove,
upsertCollectionItem as upsert,
} from './lib'
export type { QueryCondition } from './lib'
export { Timestamp, FieldValue } from 'firebase/firestore'
3 changes: 2 additions & 1 deletion dist/cjs/src/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/cjs/src/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/cjs/src/lib/getCollectionItem.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ export declare const getCollectionItem: <T>(
db: firestore.Firestore,
collectionPath: string,
docId: string
) => Promise<T>
) => Promise<T | null>
4 changes: 2 additions & 2 deletions dist/cjs/src/lib/getCollectionItem.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/cjs/src/lib/getCollectionItem.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/cjs/src/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export * from './addMultipleCollectionItems'
export * from './queryCollectionItems'
export * from './updateCollectionItem'
export * from './deleteCollectionItem'
export * from './upsertCollectionItem'
1 change: 1 addition & 0 deletions dist/cjs/src/lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/cjs/src/lib/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions dist/cjs/src/lib/upsertCollectionItem.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { firestore } from 'firebase-admin'
export type WithFieldValue<T> = {
[K in keyof T]: T[K] | firestore.FieldValue
}
/**
* Updates or inserts a document in the specified Firestore collection with the given data.
*
* @param db - The instance of the Firestore database to use.
* @param collectionPath - The path of the collection containing the document to be updated or inserted.
* @param docId - The ID of the document to be updated or inserted.
* @param params - The data to update or insert the document with.
*
* @returns A boolean indicating the success of the upsert operation.
*
* @throws Throws an exception with an error message if an error occurs.
*
* @example
* ```typescript
* import { firestore } from 'firebase-admin';
* import { upsert } from '@skeet-framework/firestore';
*
* const db = firestore();
* const upsertData: firestore.UpdateData<User> = {
* age: 31
* };
*
* async function run() {
* try {
* const path = 'Users';
* const docId = '123456'; // Assuming this ID exists in the Users collection.
* const success = await upsert<User>(db, path, docId, upsertData);
* if (success) {
* console.log(`Document with ID ${docId} upserted successfully.`);
* }
* } catch (error) {
* console.error(`Error upserting document: ${error}`);
* }
* }
*
* run();
* ```
*/
export declare const upsertCollectionItem: <T extends firestore.DocumentData>(
db: firestore.Firestore,
collectionPath: string,
docId: string,
params: firestore.UpdateData<WithFieldValue<T>>
) => Promise<boolean>
73 changes: 73 additions & 0 deletions dist/cjs/src/lib/upsertCollectionItem.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/cjs/src/lib/upsertCollectionItem.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/cjs/src/lib/version.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export declare const VERSION = '2.3.3'
export declare const VERSION = '2.4.0'
2 changes: 1 addition & 1 deletion dist/cjs/src/lib/version.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/cjs/tests/firestore_spec.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d9bc5d1

Please sign in to comment.