1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.getObjectIds = exports.getObjectId = void 0;
|
4 | const mongodb_1 = require("mongodb");
|
5 | const crypto_1 = require("crypto");
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | const getObjectId = (name) => {
|
13 | if (name === '') {
|
14 | throw new Error('Name cannot be empty');
|
15 | }
|
16 | const hash = crypto_1.createHash('sha1')
|
17 | .update(name, 'utf8')
|
18 | .digest('hex');
|
19 | return new mongodb_1.ObjectId(hash.substring(0, 24));
|
20 | };
|
21 | exports.getObjectId = getObjectId;
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | const getObjectIds = (names) => {
|
29 | return names.map(name => exports.getObjectId(name));
|
30 | };
|
31 | exports.getObjectIds = getObjectIds;
|
32 |
|
\ | No newline at end of file |