Skip to content

Commit

Permalink
docs(domain): add JSDoc to explain why prefer to use record instead o… (
Browse files Browse the repository at this point in the history
#451)

* docs(domain): add JSDoc to explain why prefer to use record instead of value domain

Co-authored-by: Teddy Paul <TdyP@users.noreply.github.com>
  • Loading branch information
P0ppoff and TdyP authored Apr 12, 2024
1 parent 7c84c65 commit 6b3e727
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
22 changes: 20 additions & 2 deletions apps/core/src/domain/record/recordDomain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,25 @@ export interface IRecordDomain {
*/
find({params, ctx}: {params: IFindRecordParams; ctx: IQueryInfos}): Promise<IListWithCursor<IRecord>>;

getRecordFieldValue(params: {
/**
* Get the value of targeted attribute with actions applied on it including metadata.
*
* Avoid requesting DB if attribute already found in `record` param.
*
* @param {Object} params
* @param params.library
* @param params.record Could be emulated with only `{ id: <real_id> }`
* @param params.attributeId
* @param params.options
* @param params.ctx
*/
getRecordFieldValue({
library,
record,
attributeId,
options,
ctx
}: {
library: string;
record: IRecord;
attributeId: string;
Expand Down Expand Up @@ -758,7 +776,7 @@ export default function ({
});

if (treeValues.length) {
// for now we look through first element (discard others if linked to multiple leaves of tree)
// for now, we look through first element (discard others if linked to multiple leaves of tree)
const treeAttrProps = await attributeDomain.getAttributeProperties({id: conf.treeColorPreview, ctx});
const ancestors = await treeRepo.getElementAncestors({
treeId: treeAttrProps.linked_tree,
Expand Down
11 changes: 11 additions & 0 deletions apps/core/src/domain/value/valueDomain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ export interface ISaveBatchValueResult {
}

export interface IValueDomain {
/**
* Call DB to get the value of an attribute.
* Prefer to use `recordDomain.getRecordFieldValue()` which is more optimized in certain situations.
*
* @param {Object} params
* @param params.library
* @param params.recordId
* @param params.attribute
* @param params.options
* @param params.ctx
*/
getValues({
library,
recordId,
Expand Down

0 comments on commit 6b3e727

Please sign in to comment.