mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-10 03:11:07 +00:00
* feat: sf metadata display * feat: update code * feat: update code * feat: lock react version * feat: bug * feat: optimize code * feat: update transalte * feat: update transalte * feat: rebase code * Feat: update code * Feat: update code --------- Co-authored-by: 杨国璇 <ygx@192.168.1.5> Co-authored-by: 杨国璇 <ygx@Hello-word.local> Co-authored-by: 杨国璇 <ygx@192.168.1.13>
27 lines
635 B
JavaScript
27 lines
635 B
JavaScript
/**
|
|
* Get table row by id
|
|
* @param {object} table
|
|
* @param {string} rowId the id of row
|
|
* @returns row, object
|
|
*/
|
|
const getRowById = (table, rowId) => {
|
|
if (!table || !table.id_row_map || !rowId) return null;
|
|
return table.id_row_map[rowId];
|
|
};
|
|
|
|
/**
|
|
* Get table rows by ids
|
|
* @param {object} table { id_row_map, ... }
|
|
* @param {array} rowsIds [ row._id, ... ]
|
|
* @returns rows, array
|
|
*/
|
|
const getRowsByIds = (table, rowsIds) => {
|
|
if (!table || !table.id_row_map || !Array.isArray(rowsIds)) return [];
|
|
return rowsIds.map((rowId) => table.id_row_map[rowId]).filter(Boolean);
|
|
};
|
|
|
|
export {
|
|
getRowById,
|
|
getRowsByIds,
|
|
};
|