MCPcopy Create free account
hub / github.com/IceClusters/icmysql / PrepareObject

Function PrepareObject

src/db/mongo/utils.js:1–22  ·  view source on GitHub ↗
(input)

Source from the content-addressed store, hash-verified

1function PrepareObject(input) {
2 if (!input) return {};
3
4 let output = {};
5
6 if (Array.isArray(input)) {
7 input.forEach((item, index) => {
8 output[index] = item;
9 });
10 } else if (typeof input === "object") {
11 if (input._id) {
12 output = {
13 ...input,
14 _id: mongodb.ObjectID(input._id)
15 };
16 } else {
17 output = { ...input };
18 }
19 }
20
21 return output;
22}
23
24module.exports = { PrepareObject }

Callers 9

MongoInsertOneFunction · 0.85
MongoInsertManyFunction · 0.85
MongoFindOneFunction · 0.85
MongoFindManyFunction · 0.85
MongoUpdateOneFunction · 0.85
MongoUpdateManyFunction · 0.85
MongoCountFunction · 0.85
MongoDeleteOneFunction · 0.85
MongoDeleteManyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected