feat(release): 1.0.0
This commit is contained in:
40
src/Storage/Operators/Insert/Result.ts
Normal file
40
src/Storage/Operators/Insert/Result.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import type { Document } from "../../../Types.js";
|
||||
|
||||
export function getInsertManyResult(documents: Document[]): InsertManyResult {
|
||||
return {
|
||||
acknowledged: true,
|
||||
insertedCount: documents.length,
|
||||
insertedIds: documents.reduce<{ [key: number]: string | number }>((map, document, index) => {
|
||||
map[index] = document.id;
|
||||
return map;
|
||||
}, {})
|
||||
};
|
||||
}
|
||||
|
||||
export function getInsertOneResult(document: Document): InsertOneResult {
|
||||
return {
|
||||
acknowledged: true,
|
||||
insertedId: document.id
|
||||
};
|
||||
}
|
||||
|
||||
export type InsertManyResult =
|
||||
| {
|
||||
acknowledged: false;
|
||||
}
|
||||
| {
|
||||
acknowledged: true;
|
||||
insertedCount: number;
|
||||
insertedIds: {
|
||||
[key: number]: string | number;
|
||||
};
|
||||
};
|
||||
|
||||
export type InsertOneResult =
|
||||
| {
|
||||
acknowledged: false;
|
||||
}
|
||||
| {
|
||||
acknowledged: true;
|
||||
insertedId: string | number;
|
||||
};
|
||||
Reference in New Issue
Block a user