Records
The Records class is a collection that stores and manages multiple Record objects. It provides methods for manipulating the records, such as adding, removing, filtering, sorting, and iterating through the collection. It includes both typical array-like methods as well as specialized functions for handling records.
Properties:
masterRecord: Record
The master record that this record is linked to. This is handy when processing data classes with details. This record belongs to a detail-data class.length: number
The number of Record instances in the collection.
Methods:
copyFrom(source: Records)
Copies data from the givenRecords
into the current collection.clear()
Clears all records from the collection.checkRight(right: string): boolean
Checks if the current user has granted permission on record’s data class.[Symbol.iterator](): Iterator<Record>
Returns an iterator for the collection, allowing the use of for...of loops to iterate through the records.add(): Record
Adds a new Record to the collection and returns it.append(record: Record): Record
Appends an existing Record to the collection and returns the same record reference.insert(index: number, record: Record): Record
Inserts a Record at the specified index in the collection.delete(index: number)
Deletes the Record at the specified index from the collection.sort(compareFunc: (r1: Record, r2: Record) => number): Records
Sorts the records in the collection using the specified comparison function and returns the sorted collection.topologicalSort(getDependenciesFunc: (r: Record) => Record[]): Records
Sorts the records in topological order based on dependencies provided by the function and returns the sorted collection.push(r: Record | Record[] | Records): number
Adds one or more records to the end of the collection. Returns the new length of the collection.filter(f: (currentValue: Record, index: number, arr: Records) => boolean): Records
Returns a new Records collection filtered based on the provided function.map(f: (element: Record) => any): any[]
Applies the provided function to each Record in the collection and returns an array of Record.find(f: (currentValue: Record, index: number, arr: Records) => boolean): Record
Returns the first Record that matches the condition specified in the function.ids(): string[]
Returns an array of the IDs of all records in the collection.findIndex(f: (currentValue: Record, index: number, arr: Records) => boolean): number
Returns the index of the first Record that matches the condition specified in the function.every(f: (currentValue: Record, index: number, arr: Records) => boolean): boolean
Tests whether all Records pass the condition specified in the function. Returns true if all records match.some(f: (currentValue: Record, index: number, arr: Records) => boolean): boolean
Tests whether at least one Record passes the condition specified in the function. Returns true if any record matches.forEach(f: (currentValue: Record, index: number, arr: Records) => any)
Executes the provided function once for each Record in the collection.includes(element: Record, start?: number): boolean
Checks if the collection includes the specified Record, optionally starting at a specific index.indexOf(element: Record, start?: number): boolean
Returns the index of the first occurrence of the specified Record in the collection, or -1 if it is not found.lastIndexOf(element: Record, start?: number): number
Returns the last index at which a given Record can be found in the collection, or -1 if it is not found.reduce(f: (total: any, currentValue: any, currentIndex: number, arr: Records) => any, initialValue: any): any
Applies the function to reduce the collection to a single value from left to right.reduceRight(f: (total: any, currentValue: any, currentIndex: number, arr: Records) => any, initialValue: any): any
Applies the function to reduce the collection to a single value from right to left.shift(): Record
Removes the first record from the collection and returns the removed record.pop(): Record
Removes the last record from the collection and returns that record .first(): Record
Returns the firstRecord
in the collection.last(): Record
Returns the lastRecord
in the collection.concat(...arrays: any[]): Records
Combines two or more Records collections and returns the combined collection.slice(start: number, end: number): Records
Returns a shallow copy of a portion of the collection into a new Records collection, based on the specified start and end indices.splice(index: number, howMany: number, ...records: any[]): Records
Changes the contents of the collection by removing or replacing existing records and/or adding new records in place.