mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-26 17:55:59 +00:00
better display of ObjectId on JSON view
This commit is contained in:
@@ -35,6 +35,8 @@
|
|||||||
return typeof value.set === 'function' ? JSONIterableMapNode : JSONIterableArrayNode;
|
return typeof value.set === 'function' ? JSONIterableMapNode : JSONIterableArrayNode;
|
||||||
case 'MapEntry':
|
case 'MapEntry':
|
||||||
return JSONMapEntryNode;
|
return JSONMapEntryNode;
|
||||||
|
case 'ObjectId':
|
||||||
|
return JSONValueNode;
|
||||||
default:
|
default:
|
||||||
return JSONValueNode;
|
return JSONValueNode;
|
||||||
}
|
}
|
||||||
@@ -64,6 +66,8 @@
|
|||||||
case 'Function':
|
case 'Function':
|
||||||
case 'Symbol':
|
case 'Symbol':
|
||||||
return raw => raw.toString();
|
return raw => raw.toString();
|
||||||
|
case 'ObjectId':
|
||||||
|
return raw => `ObjectId("${raw.$oid}")`;
|
||||||
default:
|
default:
|
||||||
return () => `<${nodeType}>`;
|
return () => `<${nodeType}>`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,9 @@
|
|||||||
.String {
|
.String {
|
||||||
color: var(--string-color);
|
color: var(--string-color);
|
||||||
}
|
}
|
||||||
|
.ObjectId {
|
||||||
|
color: var(--number-color);
|
||||||
|
}
|
||||||
.Date {
|
.Date {
|
||||||
color: var(--date-color);
|
color: var(--date-color);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
export default function objType(obj) {
|
export default function objType(obj) {
|
||||||
|
if (obj?.$oid) {
|
||||||
|
return 'ObjectId';
|
||||||
|
}
|
||||||
|
|
||||||
const type = Object.prototype.toString.call(obj).slice(8, -1);
|
const type = Object.prototype.toString.call(obj).slice(8, -1);
|
||||||
if (type === 'Object') {
|
if (type === 'Object') {
|
||||||
if (typeof obj[Symbol.iterator] === 'function') {
|
if (typeof obj[Symbol.iterator] === 'function') {
|
||||||
|
|||||||
Reference in New Issue
Block a user