@atscript/db-mongo 0.1.48 → 0.1.50
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/agg.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_mongo_filter = require("./mongo-filter-
|
|
2
|
+
const require_mongo_filter = require("./mongo-filter-AihWWQXp.cjs");
|
|
3
3
|
let _atscript_db_agg = require("@atscript/db/agg");
|
|
4
4
|
//#region src/agg.ts
|
|
5
5
|
/** Simple accumulators that map directly to `{ $<fn>: '$field' }`. */
|
package/dist/agg.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as buildMongoFilter } from "./mongo-filter-
|
|
1
|
+
import { t as buildMongoFilter } from "./mongo-filter-BsocUQG3.mjs";
|
|
2
2
|
import { resolveAlias } from "@atscript/db/agg";
|
|
3
3
|
//#region src/agg.ts
|
|
4
4
|
/** Simple accumulators that map directly to `{ $<fn>: '$field' }`. */
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_mongo_filter = require("./mongo-filter-
|
|
2
|
+
const require_mongo_filter = require("./mongo-filter-AihWWQXp.cjs");
|
|
3
3
|
let _atscript_db = require("@atscript/db");
|
|
4
4
|
let mongodb = require("mongodb");
|
|
5
5
|
//#region src/lib/collection-patcher.ts
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as buildMongoFilter } from "./mongo-filter-
|
|
1
|
+
import { t as buildMongoFilter } from "./mongo-filter-BsocUQG3.mjs";
|
|
2
2
|
import { AtscriptDbView, BaseDbAdapter, DbError, DbSpace, computeInsights, getDbFieldOp, getKeyProps } from "@atscript/db";
|
|
3
3
|
import { MongoClient, MongoServerError, ObjectId } from "mongodb";
|
|
4
4
|
//#region src/lib/collection-patcher.ts
|
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
let _atscript_db = require("@atscript/db");
|
|
2
2
|
//#region src/lib/mongo-filter.ts
|
|
3
3
|
const EMPTY = {};
|
|
4
|
+
function parseRegexString(value) {
|
|
5
|
+
if (value instanceof RegExp) return {
|
|
6
|
+
pattern: value.source,
|
|
7
|
+
flags: value.flags
|
|
8
|
+
};
|
|
9
|
+
const str = String(value);
|
|
10
|
+
const match = str.match(/^\/(.+)\/([gimsuy]*)$/);
|
|
11
|
+
if (match) return {
|
|
12
|
+
pattern: match[1],
|
|
13
|
+
flags: match[2]
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
pattern: str,
|
|
17
|
+
flags: ""
|
|
18
|
+
};
|
|
19
|
+
}
|
|
4
20
|
const mongoVisitor = {
|
|
5
21
|
comparison(field, op, value) {
|
|
6
22
|
if (op === "$eq") return { [field]: value };
|
|
23
|
+
if (op === "$regex") {
|
|
24
|
+
const { pattern, flags } = parseRegexString(value);
|
|
25
|
+
return flags ? { [field]: {
|
|
26
|
+
$regex: pattern,
|
|
27
|
+
$options: flags
|
|
28
|
+
} } : { [field]: { $regex: pattern } };
|
|
29
|
+
}
|
|
7
30
|
return { [field]: { [op]: value } };
|
|
8
31
|
},
|
|
9
32
|
and(children) {
|
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
import { walkFilter } from "@atscript/db";
|
|
2
2
|
//#region src/lib/mongo-filter.ts
|
|
3
3
|
const EMPTY = {};
|
|
4
|
+
function parseRegexString(value) {
|
|
5
|
+
if (value instanceof RegExp) return {
|
|
6
|
+
pattern: value.source,
|
|
7
|
+
flags: value.flags
|
|
8
|
+
};
|
|
9
|
+
const str = String(value);
|
|
10
|
+
const match = str.match(/^\/(.+)\/([gimsuy]*)$/);
|
|
11
|
+
if (match) return {
|
|
12
|
+
pattern: match[1],
|
|
13
|
+
flags: match[2]
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
pattern: str,
|
|
17
|
+
flags: ""
|
|
18
|
+
};
|
|
19
|
+
}
|
|
4
20
|
const mongoVisitor = {
|
|
5
21
|
comparison(field, op, value) {
|
|
6
22
|
if (op === "$eq") return { [field]: value };
|
|
23
|
+
if (op === "$regex") {
|
|
24
|
+
const { pattern, flags } = parseRegexString(value);
|
|
25
|
+
return flags ? { [field]: {
|
|
26
|
+
$regex: pattern,
|
|
27
|
+
$options: flags
|
|
28
|
+
} } : { [field]: { $regex: pattern } };
|
|
29
|
+
}
|
|
7
30
|
return { [field]: { [op]: value } };
|
|
8
31
|
},
|
|
9
32
|
and(children) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atscript/db-mongo",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.50",
|
|
4
4
|
"description": "Mongodb plugin for atscript.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"atscript",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@atscript/core": "^0.1.47",
|
|
61
61
|
"@atscript/typescript": "^0.1.47",
|
|
62
62
|
"mongodb": "^6.17.0",
|
|
63
|
-
"@atscript/db": "^0.1.
|
|
63
|
+
"@atscript/db": "^0.1.50"
|
|
64
64
|
},
|
|
65
65
|
"scripts": {
|
|
66
66
|
"postinstall": "asc -f dts",
|