cantian-mongodb 0.0.24 → 0.0.26
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/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/trash.d.ts +22 -0
- package/dist/trash.js +23 -0
- package/dist/trash.js.map +1 -0
- package/package.json +1 -1
- package/dist/util.d.ts +0 -4
- package/dist/util.js +0 -17
- package/dist/util.js.map +0 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC"}
|
package/dist/trash.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FromSchema } from 'json-schema-to-ts';
|
|
2
|
+
export declare const trashModelSchema: {
|
|
3
|
+
readonly type: "object";
|
|
4
|
+
readonly properties: {
|
|
5
|
+
readonly _id: {
|
|
6
|
+
readonly type: "string";
|
|
7
|
+
};
|
|
8
|
+
readonly source: {
|
|
9
|
+
readonly type: "string";
|
|
10
|
+
};
|
|
11
|
+
readonly origin: {
|
|
12
|
+
readonly type: "object";
|
|
13
|
+
};
|
|
14
|
+
readonly deletedAt: {
|
|
15
|
+
readonly type: "string";
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
readonly additionalProperties: false;
|
|
19
|
+
readonly required: readonly ["source", "origin", "deletedAt"];
|
|
20
|
+
};
|
|
21
|
+
export type TrashModel = FromSchema<typeof trashModelSchema>;
|
|
22
|
+
export declare const moveToTrash: (source: string, origin: any) => Promise<void>;
|
package/dist/trash.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { db } from './mongoClient.js';
|
|
2
|
+
export const trashModelSchema = {
|
|
3
|
+
type: 'object',
|
|
4
|
+
properties: {
|
|
5
|
+
_id: { type: 'string' },
|
|
6
|
+
source: { type: 'string' },
|
|
7
|
+
origin: { type: 'object' },
|
|
8
|
+
deletedAt: { type: 'string' },
|
|
9
|
+
},
|
|
10
|
+
additionalProperties: false,
|
|
11
|
+
required: ['source', 'origin', 'deletedAt'],
|
|
12
|
+
};
|
|
13
|
+
const trashCollection = db.collection('trash');
|
|
14
|
+
export const moveToTrash = async (source, origin) => {
|
|
15
|
+
if (origin) {
|
|
16
|
+
await trashCollection.insertOne({
|
|
17
|
+
source,
|
|
18
|
+
origin,
|
|
19
|
+
deletedAt: new Date().toISOString(),
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=trash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trash.js","sourceRoot":"","sources":["../src/trash.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAEtC,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACvB,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC1B,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC1B,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;KAC9B;IACD,oBAAoB,EAAE,KAAK;IAC3B,QAAQ,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,WAAW,CAAC;CACd,CAAC;AAIhC,MAAM,eAAe,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AAE/C,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAAE,MAAc,EAAE,MAAW,EAAE,EAAE;IAC/D,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,eAAe,CAAC,SAAS,CAAC;YAC9B,MAAM;YACN,MAAM;YACN,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC"}
|
package/package.json
CHANGED
package/dist/util.d.ts
DELETED
package/dist/util.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export const normalizeModelSchema = async (options) => {
|
|
2
|
-
const { schema, deleteFields } = options;
|
|
3
|
-
const newSchema = structuredClone(schema);
|
|
4
|
-
if (newSchema.properties) {
|
|
5
|
-
if (newSchema.properties._id) {
|
|
6
|
-
newSchema.properties.id = newSchema.properties._id;
|
|
7
|
-
delete newSchema.properties._id;
|
|
8
|
-
}
|
|
9
|
-
if (deleteFields?.length) {
|
|
10
|
-
for (let deleteField of deleteFields) {
|
|
11
|
-
delete newSchema.properties[deleteField];
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
return newSchema;
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=util.js.map
|
package/dist/util.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EAAE,OAA4C,EAAE,EAAE;IACzF,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IACzC,MAAM,SAAS,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IAC1C,IAAI,SAAS,CAAC,UAAU,EAAE,CAAC;QACzB,IAAI,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC;YAC7B,SAAS,CAAC,UAAU,CAAC,EAAE,GAAG,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC;YACnD,OAAO,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC;QAClC,CAAC;QACD,IAAI,YAAY,EAAE,MAAM,EAAE,CAAC;YACzB,KAAK,IAAI,WAAW,IAAI,YAAY,EAAE,CAAC;gBACrC,OAAO,SAAS,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC"}
|