mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
fixed mongo update condition
This commit is contained in:
parent
2649a0174d
commit
8a13d88c3e
@ -490,7 +490,11 @@
|
||||
|
||||
function getSelectedDataJson(forceArray = false) {
|
||||
const cells = cellsToRegularCells(selectedCells);
|
||||
const data = cells.map(cell => grider.getRowData(cell[0])[realColumnUniqueNames[cell[1]]]);
|
||||
const data = cells.map(cell => {
|
||||
const rowData = grider.getRowData(cell[0]);
|
||||
if (!rowData) return null;
|
||||
return rowData[realColumnUniqueNames[cell[1]]];
|
||||
});
|
||||
if (!data.every(x => _.isArray(x) || _.isPlainObject(x))) return null;
|
||||
if (data.length == 0) return null;
|
||||
if (data.length == 1 && _.isPlainObject(data[0]) && !forceArray) return data[0];
|
||||
|
@ -4,6 +4,7 @@
|
||||
import FormSubmit from '../forms/FormSubmit.svelte';
|
||||
import JSONTree from '../jsontree/JSONTree.svelte';
|
||||
import AceEditor from '../query/AceEditor.svelte';
|
||||
import newQuery from '../query/newQuery';
|
||||
|
||||
import ModalBase from './ModalBase.svelte';
|
||||
import { closeCurrentModal } from './modalTools';
|
||||
@ -29,6 +30,17 @@
|
||||
}}
|
||||
/>
|
||||
<FormStyledButton type="button" value="Close" on:click={closeCurrentModal} />
|
||||
<FormStyledButton
|
||||
type="button"
|
||||
value="Open script"
|
||||
on:click={() => {
|
||||
newQuery({
|
||||
initialData: script,
|
||||
});
|
||||
|
||||
closeCurrentModal();
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</ModalBase>
|
||||
</FormProvider>
|
||||
|
@ -21,7 +21,9 @@ const mongoIdRegex = /^[0-9a-f]{24}$/;
|
||||
function convertConditionInternal(condition) {
|
||||
if (condition && _.isString(condition._id) && condition._id.match(mongoIdRegex)) {
|
||||
return {
|
||||
_id: ObjectId(condition._id),
|
||||
_id: {
|
||||
$in: [condition._id, ObjectId(condition._id)],
|
||||
},
|
||||
};
|
||||
}
|
||||
return condition;
|
||||
|
@ -7,7 +7,7 @@ const mongoIdRegex = /^[0-9a-f]{24}$/;
|
||||
|
||||
function getConditionPreview(condition) {
|
||||
if (condition && _isString(condition._id) && condition._id.match(mongoIdRegex)) {
|
||||
return `{ _id: ObjectId('${condition._id}') }`;
|
||||
return `{ _id: { $in: ['${condition._id}', ObjectId('${condition._id}')] } }`;
|
||||
}
|
||||
return JSON.stringify(condition);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user