fixed mongo update condition

This commit is contained in:
Jan Prochazka 2021-12-02 14:15:07 +01:00
parent 2649a0174d
commit 8a13d88c3e
4 changed files with 21 additions and 3 deletions

View File

@ -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];

View File

@ -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>

View File

@ -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;

View File

@ -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);
}