changeSetInsertDocuments improved

This commit is contained in:
Jan Prochazka 2024-07-10 12:08:23 +02:00
parent 9d5c7e6df2
commit 5c080568d8

View File

@ -498,7 +498,12 @@ export function changeSetInsertNewRow(changeSet: ChangeSet, name?: NamedObjectIn
};
}
export function changeSetInsertDocuments(changeSet: ChangeSet, documents: any[], name?: NamedObjectInfo): ChangeSet {
export function changeSetInsertDocuments(
changeSet: ChangeSet,
documents: any[],
name?: NamedObjectInfo,
insertIfNotExistsFieldNames?: string[]
): ChangeSet {
const insertedRows = getChangeSetInsertedRows(changeSet, name);
return {
...changeSet,
@ -508,6 +513,7 @@ export function changeSetInsertDocuments(changeSet: ChangeSet, documents: any[],
...name,
insertedRowIndex: insertedRows.length + index,
fields: doc,
insertIfNotExistsFields: insertIfNotExistsFieldNames ? _.pick(doc, insertIfNotExistsFieldNames) : null,
})),
],
};