@dataclouder/ngx-core 0.2.1 → 0.2.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/package.json
CHANGED
|
@@ -708,15 +708,11 @@ declare abstract class EntityCommunicationService<T> {
|
|
|
708
708
|
* @deprecated Use createOrUpdate(payload) instead.
|
|
709
709
|
*/
|
|
710
710
|
createOperation(payload: Partial<T>): Promise<T>;
|
|
711
|
-
query(filterConfig: FiltersConfig): Promise<IFilterQueryResponse<T>>;
|
|
712
711
|
/**
|
|
713
|
-
|
|
714
|
-
|
|
712
|
+
* @deprecated This was changed to use operation() method., refactor your code to use operation.
|
|
713
|
+
*/
|
|
714
|
+
query(filterConfig: FiltersConfig): Promise<IFilterQueryResponse<T>>;
|
|
715
715
|
update(id: string, update: any): Promise<T>;
|
|
716
|
-
/**
|
|
717
|
-
* @deprecated Use createOrUpdate or updateOne instead.
|
|
718
|
-
*/
|
|
719
|
-
updateOneOperation(id: string, payload: any): Promise<T>;
|
|
720
716
|
partialUpdate(id: string, partialUpdates: Partial<T>): Promise<T>;
|
|
721
717
|
remove(id: string): Promise<void>;
|
|
722
718
|
/**
|
|
@@ -725,8 +721,47 @@ declare abstract class EntityCommunicationService<T> {
|
|
|
725
721
|
removeOperation(id: string): Promise<any>;
|
|
726
722
|
clone(id: string, overrides?: Partial<T>): Promise<T>;
|
|
727
723
|
getFixedQuery(): Record<string, any>;
|
|
724
|
+
/**
|
|
725
|
+
* Executes a single database operation through a flexible interface provided by the backend's `@dataclouder/nest-mongo` ecosystem.
|
|
726
|
+
* By leveraging this endpoint, clients can safely execute any common MongoDB operation by passing the appropriate configuration.
|
|
727
|
+
*
|
|
728
|
+
* @param params - The payload containing the operation details.
|
|
729
|
+
* @param params.action - The database action to perform. Valid options are:
|
|
730
|
+
* - `'findOne'`: Fetch the first document matching `query`.
|
|
731
|
+
* - `'find'`: Retrieve multiple documents matching `query` (supports `projection` and `options`).
|
|
732
|
+
* - `'create'`: Insert a new document utilizing `payload`.
|
|
733
|
+
* - `'updateOne'`: Modify the first document matching `query` using update operators in `payload`.
|
|
734
|
+
* - `'updateMany'`: Modify all documents matching `query` using `payload`.
|
|
735
|
+
* - `'deleteOne'`: Remove the first document matching `query`.
|
|
736
|
+
* - `'deleteMany'`: Remove all documents matching `query`.
|
|
737
|
+
* - `'aggregate'`: Run an aggregation pipeline provided in `payload` as an array.
|
|
738
|
+
* - `'clone'`: Create a copy of a document identified by `query`, overriding properties with `payload`.
|
|
739
|
+
* @param params.query - The MongoDB query used to select documents (e.g., `{ status: "active" }`).
|
|
740
|
+
* @param params.payload - The data for `create`, `updateOne`, `updateMany` (update operators), or the aggregation pipeline array.
|
|
741
|
+
* @param params.projection - Specifies the fields to return for `find` or `findOne` (e.g., `{ name: 1, email: 1 }`).
|
|
742
|
+
* @param params.options - Additional options for `find` operations like `limit`, `skip`, or `sort` (e.g., `{ limit: 10 }`).
|
|
743
|
+
*
|
|
744
|
+
* @example
|
|
745
|
+
* // Find multiple documents
|
|
746
|
+
* this.operation({
|
|
747
|
+
* action: 'find',
|
|
748
|
+
* query: { status: 'active' },
|
|
749
|
+
* projection: { name: 1 },
|
|
750
|
+
* options: { limit: 10, sort: { createdAt: -1 } }
|
|
751
|
+
* });
|
|
752
|
+
*
|
|
753
|
+
* @example
|
|
754
|
+
* // Update a single document
|
|
755
|
+
* this.operation({
|
|
756
|
+
* action: 'updateOne',
|
|
757
|
+
* query: { _id: '123' },
|
|
758
|
+
* payload: { $set: { status: 'inactive' } }
|
|
759
|
+
* });
|
|
760
|
+
*
|
|
761
|
+
* @returns A Promise resolving to the result of the database operation.
|
|
762
|
+
*/
|
|
728
763
|
operation(params: {
|
|
729
|
-
action: 'findOne' | 'find' | 'create' | 'updateOne' | 'updateMany' | 'deleteOne' | 'deleteMany' | 'aggregate' | '
|
|
764
|
+
action: 'findOne' | 'find' | 'create' | 'updateOne' | 'updateMany' | 'deleteOne' | 'deleteMany' | 'aggregate' | 'clone';
|
|
730
765
|
query?: any;
|
|
731
766
|
payload?: any;
|
|
732
767
|
projection?: any;
|