-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathcollection-field.ts
41 lines (38 loc) · 1.39 KB
/
collection-field.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* Copyright (c) 2020 SAP SE or an SAP affiliate company. All rights reserved. */
import { EntityBase } from '../entity';
import { EdmTypeShared } from '../edm-types';
import { SelectableEdmTypeField } from './edm-type-field';
import { Field } from './field';
import { ComplexTypeNamespace } from './complex-type-namespace';
import { getEntityConstructor } from './complex-type-field';
import { ConstructorOrField } from './constructor-or-field';
/**
*
* Represents a static field of an entity or complex type.
*
* @typeparam EntityT - Type of the entity the field belongs to
* @typeparam FieldT - Type of the entries of the collection in the field
*/
export class CollectionField<
EntityT extends EntityBase,
FieldT extends EdmTypeShared<'any'> | Record<string, any> = any
>
extends Field<EntityT>
implements SelectableEdmTypeField {
readonly selectable: true;
/**
*
* Creates an instance of CollectionField.
*
* @param fieldName - Actual name of the field used in the OData request.
* @param fieldOf - The constructor of the entity or the complex type field this field belongs to.
* @param _fieldType - Type of the field according to the metadata description.
*/
constructor(
fieldName: string,
fieldOf: ConstructorOrField<EntityT>,
readonly _fieldType: FieldT | ComplexTypeNamespace<FieldT>
) {
super(fieldName, getEntityConstructor(fieldOf));
}
}