mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-26 06:26:00 +00:00
suport mongo ObjectId in data editor
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<script lang="ts" context="module">
|
||||
function getEditedValue(value) {
|
||||
if (value?.type == 'Buffer' && _.isArray(value.data)) return arrayToHexString(value.data);
|
||||
if (value?.$oid) return `ObjectId("${value?.$oid}")`;
|
||||
if (_.isPlainObject(value) || _.isArray(value)) return JSON.stringify(value);
|
||||
return value;
|
||||
}
|
||||
@@ -12,6 +13,13 @@
|
||||
data: hexStringToArray(newString),
|
||||
};
|
||||
}
|
||||
if (_.isString(newString)) {
|
||||
const m = newString.match(/ObjectId\("([0-9a-f]{24})"\)/);
|
||||
if (m) {
|
||||
return { $oid: m[1] };
|
||||
}
|
||||
}
|
||||
|
||||
return newString;
|
||||
}
|
||||
</script>
|
||||
@@ -28,7 +36,7 @@
|
||||
export let onSetValue;
|
||||
export let width;
|
||||
export let cellValue;
|
||||
export let fillParent=false;
|
||||
export let fillParent = false;
|
||||
|
||||
let domEditor;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
showModal(EditJsonModal, {
|
||||
json: rowData,
|
||||
onSave: value => {
|
||||
if (rowData._id && value._id != rowData._id) {
|
||||
if (grider.getRowStatus(rowIndex).status != 'inserted' && rowData._id && value._id != rowData._id) {
|
||||
showModal(ErrorMessageModal, { message: '_id attribute cannot be changed' });
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user