访问类型为"list"的对象属性时,将返回此类的实例。

列表的行为大多与普通的 JavaScript 数组相同,但列表只能存储单一类型的值(由列表的属性typeoptional表示),并且只能在写事务(write transaction)中进行修改。

类型参数

  • T =未知

层次结构(查看完整

implements

属性

[unscopes] {
    [unscopes]?: 布尔
    长度?: 布尔
    [iterator]?: 注意到
    at?: 注意到
    concat?: 注意到
    copyWithin?: 注意到
    条目?: 注意到
    every?: 注意到
    填写?: 注意到
    筛选器?: 注意到
    find?: 注意到
    findIndex?: 注意到
    平面?: 注意到
    flatMap?: 注意到
    forEach?: 注意到
    包括?: 注意到
    indexOf?: 注意到
    连接 (JOIN)?: 注意到
    密钥?: 注意到
    lastIndexOf?: 注意到
    地图?: 注意到
    Pop?: 注意到
    推动?: 注意到
    化简(reduce)?: 注意到
    reduceRight?: 注意到
    reverse?: 注意到
    转变?: 注意到
    slice?: 注意到
    some?: 注意到
    排序?: 注意到
    splice?: 注意到
    toLocaleString?: 注意到
    toString?: 注意到
    unshift?: 注意到
    values?: 注意到
} = ...

一个对象,其 true 属性是从关联对象的 'with' 环境绑定中排除的属性。

类型声明

  • Optional Readonly [unscopes]?: 布尔

    一个对象,其属性的值为“true”,但在“with”语句中使用时,这些对象将不存在。

  • Optional 长度?: 布尔

    获取或设置数组的长度。 该数字比数组中的最高索引大 1。

访问器

  • get length ( ) : number
  • 返回数字

    列表中值的数量。

  • 设置长度( value ) : void
  • 参数

    • value : number

    返回void

    抛出异常

    由于无法分配长度属性,因此出现错误。

  • 获取可选值( ) : boolean
  • null是否为collection的有效值。

    返回布尔值

    null是否为collection的有效值。

方法

  • 添加监听器callback ,当实时collection实例发生更改时将调用该监听器。

    参数

    • 回调 : CollectionChangeCallback < T , [ number , T ] >

      发生更改时要调用的函数。

    • Optional keyPaths : string | string []

      指示与侦听器相关的更改的下限。 这是一个下限,因为如果添加了多个侦听器(每个侦听器都有自己的keyPaths ),这些键路径的并集将确定被视为与在collection上注册的所有侦听器相关的更改。换言之:如果存在具有不同键路径的其他侦听器,则侦听器触发的次数可能会超过键路径指定的次数。

    返回void

    注意

    deletions and oldModifications report the indices in the collection before the change happened, while插入and newModifications report the indices into the new version of the collection. @throws A {@link TypeAssertionError} if回调 is not a function. @example wines.addListener((collection, changes) => { // collection === wines console.log( ${changes.insertions.length} 插入); console.log( ${changes.oldModifications.length} oldModifications ); console.log( ${changes.newModifications.length} newModifications ); console.log( ${changes.deletions.length} 删除); console.log(集合的新大小:${collection.length} ); }); @example wines.addListener((collection, changes) => { console.log("A wine's brand might have changed"); }, ["brand"]); @note Adding the listener is an asynchronous operation, so the callback is invoked the first time to notify the caller when the listener has been added. Thus, when the callback is invoked the first time it will contain empty arrays for each property in the 更改` 对象。

  • 参数

    • index : number

    返回undefined | T

    数组中给定索引处的元素;如果给定索引处没有元素,则返回undefined

    Array.prototype.at()

    参数

    index - The index of the element to return from the array. 如果索引为负数,则返回array.length + index处的元素。

  • 计算集合中值的平均值或集合中所有对象中给定属性的平均值,如果集合为空,则为undefined

    仅支持 int、float 和 double 属性。 此方法会完全忽略null值,也不会计入平均值。

    参数

    • Optional 属性 : string

      对于对象集合,要计算平均值的属性。

    返回undefined | number

    总和。

    抛出异常

    如果不存在具有该名称的属性或者属性不是数字,则出现错误。

  • 类型参数

    • S

    参数

    • predicate : ( ( value , index , array ) => value is S )
        • (value , index , array ) 值为 S
        • 参数

          • T
          • index : number
          • array : readonly T []

          返回 值为 S

    • Optional thisArg : any

    返回值为只读S []

    true 如果回调为每个collection元素返回一个真值;否则为false

    Array.prototype.every()

    参数

    predicate - 用于测试每个元素的函数。

    参数

    predicate.value — collection中正在处理的当前元素。

    参数

    predicate.index - 集合中正在处理的当前元素的索引。

    参数

    predicate.array — 调用了collectionevery

    参数

    thisArg - this关键字可以在谓词函数中引用的对象。 如果省略thisArg ,则将undefined用作this值。

  • 参数

    • predicate : ( ( value , index , array ) => unknown )
        • (索引数组 未知
        • 参数

          • T
          • index : number
          • array : readonly T []

          返回未知

    • Optional thisArg : any

    返回布尔值

    true 如果回调为每个collection元素返回一个真值;否则为false

    Array.prototype.every()

    参数

    predicate - 用于测试每个元素的函数。

    参数

    predicate.value — collection中正在处理的当前元素。

    参数

    predicate.index - 集合中正在处理的当前元素的索引。

    参数

    predicate.array — 调用了collectionevery

    参数

    thisArg - this关键字可以在谓词函数中引用的对象。 如果省略thisArg ,则将undefined用作this值。

  • 类型参数

    • S

    参数

    • predicate : ( ( value , index , array ) => value is S )
        • (value , index , array ) 值为 S
        • 参数

          • T
          • index : number
          • array : readonly T []

          返回 值为 S

    • Optional thisArg : any

    返回S []

    一个新数组,其中包含predicate函数返回true的collection元素。

    Array.prototype.filter()

    参数

    谓词 - 最多接受三个参数的函数。 filter方法为collection中的每个元素调用predicate函数一次。

    参数

    predicate.value — collection中正在处理的当前元素。

    参数

    predicate.index - 集合中正在处理的当前元素的索引。

    参数

    predicate.array — 调用了collectionfilter

    参数

    thisArg - this关键字可以在predicate函数中引用的对象。 如果省略thisArg ,则使用undefined作为this值。

  • 参数

    • predicate : ( ( value , index , array ) => unknown )
        • (索引数组 未知
        • 参数

          • T
          • index : number
          • array : readonly T []

          返回未知

    • Optional thisArg : any

    返回T []

    一个新数组,其中包含predicate函数返回true的collection元素。

    Array.prototype.filter()

    参数

    谓词 - 最多接受三个参数的函数。 filter方法为collection中的每个元素调用predicate函数一次。

    参数

    predicate.value — collection中正在处理的当前元素。

    参数

    predicate.index - 集合中正在处理的当前元素的索引。

    参数

    predicate.array — 调用了collectionfilter

    参数

    thisArg - this关键字可以在predicate函数中引用的对象。 如果省略thisArg ,则使用undefined作为this值。

  • 返回表示此collection按所提供的查询进行筛选的新结果

    参数

    • queryString : string

      用于从collection中筛选对象的查询。

    • Rest ...args : unknown []

      每个后续参数都由占位符使用(例如 $0$1$2 、...)在查询中。

    返回结果< T >

    根据提供的查询筛选结果。

    抛出异常

    如果传递给该方法的查询或任何其他参数无效,则出现错误。

    注意

    目前仅 Realm 对象集合支持此功能。

    例子

    let merlots = wines.filtered('variety == "Merlot" && vintage <= $0', maxYear);
    
  • 类型参数

    • S

    参数

    • predicate : ( ( this , value , index , obj ) => value is S )
        • (this , value , index , obj ) 值为 S
        • 参数

          • this : void
          • T
          • index : number
          • obj : T []

          返回 值为 S

    • Optional thisArg : any

    返回undefined | S

    数组中满足所提供测试函数的第一个元素的值。 否则,返回undefined

    Array.prototype.find()

    参数

    谓词 - 最多接受三个参数的函数。 find方法为collection中的每个元素调用predicate函数一次。

    参数

    predicate.value — 元素的值。

    参数

    predicate.index - 元素的索引。

    参数

    predicate.obj - 正在遍历的对象。

    参数

    thisArg - this关键字可以在predicate函数中引用的对象。 如果省略thisArg ,则使用undefined作为this值。

  • 类型参数

    • t

    参数

    • predicate : ( ( value , index , obj ) => unknown )
        • (value , index , obj ) : unknown
        • 参数

          • T
          • index : number
          • obj : T []

          返回未知

    • Optional thisArg : any

    返回undefined | T

    数组中满足所提供测试函数的第一个元素的值。 否则,返回undefined

    Array.prototype.find()

    参数

    谓词 - 最多接受三个参数的函数。 find方法为collection中的每个元素调用predicate函数一次。

    参数

    predicate.value — 元素的值。

    参数

    predicate.index - 元素的索引。

    参数

    predicate.obj - 正在遍历的对象。

    参数

    thisArg - this关键字可以在predicate函数中引用的对象。 如果省略thisArg ,则使用undefined作为this值。

  • 参数

    • predicate : ( ( value , index , obj ) => unknown )
        • (value , index , obj ) : unknown
        • 参数

          • T
          • index : number
          • obj : readonly T []

          返回未知

    • Optional thisArg : any

    返回数字

    数组中满足所提供测试函数的第一个元素的索引。 否则,返回 -1。

    Array.prototype.findIndex()

    参数

    谓词 - 最多接受三个参数的函数。 findIndex方法为collection中的每个元素调用predicate函数一次。

    参数

    predicate.value — 元素的值。

    参数

    predicate.index - 元素的索引。

    参数

    predicate.obj - 正在遍历的对象。

    参数

    thisArg - this关键字可以在predicate函数中引用的对象。 如果省略thisArg ,则使用undefined作为this值。

  • 类型参数

    • u

    • = undefined

    参数

    • callback : ( ( this , value , index , array ) => U | readonly U [] )
        • (this , value , index , array ) : U | readonly U []
        • 参数

          • this :
          • T
          • index : number
          • array : T []

          返回U | readonly U []

    • Optional thisArg : This

    返回U []

    一个新数组,其中每个元素都是回调函数的结果,并展平到深度 1。

    Array.prototype.flatMap()

    参数

    callback — 生成新数组元素的函数,采用三个参数:

    参数

    callback.currentValue - 数组中正在处理的当前元素。

    参数

    callback.index — 数组中当前正在处理的元素的索引。

    参数

    callback.array — 调用了数组flatMap

    参数

    thisArg - 执行回调时用作 this 的值。

  • 参数

    • callbackfn : ( ( value , index , array ) => void )
        • (,索引,数组) : void
        • 参数

          • T
          • index : number
          • array : readonly T []

          返回void

    • Optional thisArg : any

    返回void

    Array.prototype.forEach()

    参数

    callbackfn — 最多接受三个参数的函数。 forEach为collection中的每个元素调用一次 callbackfn 函数。

    参数

    callbackfn.value — collection中正在处理的当前元素。

    参数

    callbackfn.index — collection中正在处理的当前元素的索引。

    参数

    callbackfn.array — 调用了collection forEach

    参数

    thisArg - this关键字可以在callbackfn函数中引用的对象。 如果省略thisArg ,则使用undefined作为this值。

  • 参数

    • searchElement : T
    • Optional fromIndex : number

    返回布尔值

    true 如果在数组中找到searchElement ;否则为false

    Array.prototype.includes()

    参数

    searchElement - 要搜索的元素。

    参数

    fromIndex - 此数组中开始搜索searchElement的位置。 负值从 array.length + fromIndex 的索引按 asc 搜索。

    注意

    fromIndex is currently not supported. 因此,所有搜索都从索引 0 开始。

  • 参数

    • searchElement : T
    • Optional fromIndex : number

    返回数字

    在collection中可以找到给定元素的第一个索引,如果不存在,则为 -1。

    Array.prototype.indexOf()

    参数

    searchElement - 要在collection中查找的元素。

    参数

    fromIndex - 开始搜索的collection索引。如果省略,则从索引 0 开始搜索。

    注意

    fromIndex is currently not supported. 因此,所有搜索都从索引 0 开始。

  • 参数

    • searchElement : T
    • Optional fromIndex : number

    返回数字

    在collection中可以找到给定元素的最后一个索引,如果不存在,则为 -1。从fromIndex开始向后搜索collection。

    Array.prototype.lastIndexOf()

    参数

    searchElement - 要在collection中查找的元素。

    参数

    fromIndex - 开始搜索的collection索引。如果省略,则从最后一个索引开始搜索。

  • 类型参数

    • u

    参数

    • callbackfn : ( ( value , index , array ) => U )
        • (,索引,数组) : U
        • 参数

          • T
          • index : number
          • array : readonly T []

          返回U

    • Optional thisArg : any

    返回U []

    一个新数组,其中包含对collection中每个元素调用callbackfn函数的结果。

    Array.prototype.map()

    参数

    callbackfn — 最多接受三个参数的函数。 map方法为collection中的每个元素调用callbackfn函数一次。

    参数

    callbackfn.value — collection中正在处理的当前元素。

    参数

    callbackfn.index — collection中正在处理的当前元素的索引。

    参数

    callbackfn.array — 调用了collection map

    参数

    thisArg - this关键字可以在callbackfn函数中引用的对象。 如果省略thisArg ,则使用undefined作为this值。

  • 返回集合中所有对象中值或给定属性的最大值;如果集合为空,则返回undefined

    仅支持 int、float、double 和 date 属性。 此方法会完全忽略null值,因此不会返回该值。

    参数

    • Optional 属性 : string

      对于collection的对象,要取最大值的属性。

    返回undefined |编号|日期

    最大值。

    抛出异常

    如果不存在具有该名称的属性或者属性不是数字/日期,则出现错误。

  • 返回集合中值的最小值或集合中所有对象中给定属性的最小值;如果集合为空,则返回undefined

    仅支持 int、float、double 和 date 属性。 此方法会完全忽略null值,因此不会返回该值。

    参数

    • Optional 属性 : string

      对于collection的对象,要取最小值的属性。

    返回undefined |编号|日期

    最小值。

    抛出异常

    如果不存在具有该名称的属性或者属性不是数字/日期,则抛出 TypeAssertionError

  • 将列表的一个元素从一个索引移动到另一个索引。

    参数

    • from : number

      要移动的元素的索引。

    • to : number

      元素的目标索引。

    返回void

    抛出异常

    如果不在写事务中,或者任何输入索引小于 0 或大于或等于列表的大小,则抛出断言错误

  • 从列表中删除最后一个值并将其返回。

    返回undefined | T

    最后一个值,如果列表为空,则为 undefined。

    抛出异常

    如果不在写事务(write transaction)中,则抛出 AssertionError

  • 将一个或多个值添加到列表末尾

    参数

    • Rest ...items : T []

      要添加到列表的值。

    返回数字

    添加值后列表的新长度。

    抛出异常

    如果值不是可以存储在列表中的类型,或者添加到列表的对象与列表的ObjectSchema不匹配,则抛出 {TypeError}。

    抛出异常

    如果不在写事务(write transaction)中,则抛出断言错误

  • 参数

    • callbackfn : ( ( previousValue , currentValue , currentIndex , array ) => T )
        • (previousValuecurrentValuecurrentIndexarray ) : T
        • 参数

          • previousValue : T
          • currentValue : T
          • currentIndex : number
          • array : readonly T []

          返回T

    返回T

    减少所产生的值。

    Array.prototype.reduce()

    参数

    callbackfn — 最多接受四个参数的函数。 reduce方法为collection中的每个元素调用callbackfn函数一次。

    参数

    callbackfn.previousValue - 上次调用callbackfn函数或initialValue (如果已提供)时返回的值。 (见下文。)

    参数

    callbackfn.currentValue - collection中正在处理的当前元素。

    参数

    callbackfn.currentIndex - 集合中正在处理的当前元素的索引。

    参数

    callbackfn.array — 调用了collection reduce

    参数

    初始值 - 如果指定了initialValue ,则用作开始累加的初始值。 首次调用callbackfn函数时会将此值作为参数而不是元素值提供。

  • 参数

    • callbackfn : ( ( previousValue , currentValue , currentIndex , array ) => T )
        • (previousValuecurrentValuecurrentIndexarray ) : T
        • 参数

          • previousValue : T
          • currentValue : T
          • currentIndex : number
          • array : readonly T []

          返回T

    • 初始值T

    返回T

    减少所产生的值。

    Array.prototype.reduce()

    参数

    callbackfn — 最多接受四个参数的函数。 reduce方法为collection中的每个元素调用callbackfn函数一次。

    参数

    callbackfn.previousValue - 上次调用callbackfn函数或initialValue (如果已提供)时返回的值。 (见下文。)

    参数

    callbackfn.currentValue - collection中正在处理的当前元素。

    参数

    callbackfn.currentIndex - 集合中正在处理的当前元素的索引。

    参数

    callbackfn.array — 调用了collection reduce

    参数

    初始值 - 如果指定了initialValue ,则用作开始累加的初始值。 首次调用callbackfn函数时会将此值作为参数而不是元素值提供。

  • 类型参数

    • u

    参数

    • callbackfn : ( ( previousValue , currentValue , currentIndex , array ) => U )
        • (previousValuecurrentValuecurrentIndexarray ) : U
        • 参数

          • previousValue : U
          • currentValue : T
          • currentIndex : number
          • array : readonly T []

          返回U

    • 初始值U

    返回U

    减少所产生的值。

    Array.prototype.reduce()

    参数

    callbackfn — 最多接受四个参数的函数。 reduce方法为collection中的每个元素调用callbackfn函数一次。

    参数

    callbackfn.previousValue - 上次调用callbackfn函数或initialValue (如果已提供)时返回的值。 (见下文。)

    参数

    callbackfn.currentValue - collection中正在处理的当前元素。

    参数

    callbackfn.currentIndex - 集合中正在处理的当前元素的索引。

    参数

    callbackfn.array — 调用了collection reduce

    参数

    初始值 - 如果指定了initialValue ,则用作开始累加的初始值。 首次调用callbackfn函数时会将此值作为参数而不是元素值提供。

  • 参数

    • callbackfn : ( ( previousValue , currentValue , currentIndex , array ) => T )
        • (previousValuecurrentValuecurrentIndexarray ) : T
        • 参数

          • previousValue : T
          • currentValue : T
          • currentIndex : number
          • array : readonly T []

          返回T

    返回T

    减少所产生的值。

    Array.prototype.reduceRight()

    参数

    callbackfn — 最多接受四个参数的函数。 reduceRight方法为collection中的每个元素调用callbackfn函数一次。

    参数

    callbackfn.previousValue - 上次调用callbackfn函数或initialValue (如果已提供)时返回的值。 (见下文。)

    参数

    callbackfn.currentValue - collection中正在处理的当前元素。

    参数

    callbackfn.currentIndex - 集合中正在处理的当前元素的索引。

    参数

    callbackfn.array — 调用了collection reduceRight

    参数

    初始值 - 如果指定了initialValue ,则用作开始累加的初始值。 首次调用callbackfn函数时会将此值作为参数而不是元素值提供。

  • 参数

    • callbackfn : ( ( previousValue , currentValue , currentIndex , array ) => T )
        • (previousValuecurrentValuecurrentIndexarray ) : T
        • 参数

          • previousValue : T
          • currentValue : T
          • currentIndex : number
          • array : readonly T []

          返回T

    • 初始值T

    返回T

    减少所产生的值。

    Array.prototype.reduceRight()

    参数

    callbackfn — 最多接受四个参数的函数。 reduceRight方法为collection中的每个元素调用callbackfn函数一次。

    参数

    callbackfn.previousValue - 上次调用callbackfn函数或initialValue (如果已提供)时返回的值。 (见下文。)

    参数

    callbackfn.currentValue - collection中正在处理的当前元素。

    参数

    callbackfn.currentIndex - 集合中正在处理的当前元素的索引。

    参数

    callbackfn.array — 调用了collection reduceRight

    参数

    初始值 - 如果指定了initialValue ,则用作开始累加的初始值。 首次调用callbackfn函数时会将此值作为参数而不是元素值提供。

  • 类型参数

    • u

    参数

    • callbackfn : ( ( previousValue , currentValue , currentIndex , array ) => U )
        • (previousValuecurrentValuecurrentIndexarray ) : U
        • 参数

          • previousValue : U
          • currentValue : T
          • currentIndex : number
          • array : readonly T []

          返回U

    • 初始值U

    返回U

    减少所产生的值。

    Array.prototype.reduceRight()

    参数

    callbackfn — 最多接受四个参数的函数。 reduceRight方法为collection中的每个元素调用callbackfn函数一次。

    参数

    callbackfn.previousValue - 上次调用callbackfn函数或initialValue (如果已提供)时返回的值。 (见下文。)

    参数

    callbackfn.currentValue - collection中正在处理的当前元素。

    参数

    callbackfn.currentIndex - 集合中正在处理的当前元素的索引。

    参数

    callbackfn.array — 调用了collection reduceRight

    参数

    初始值 - 如果指定了initialValue ,则用作开始累加的初始值。 首次调用callbackfn函数时会将此值作为参数而不是元素值提供。

  • 删除列表中指定索引处的元素。

    参数

    • index : number

      要删除的元素的索引。

    返回void

    抛出异常

    如果不在写事务(write transaction)内,或者输入索引小于 0 或大于或等于列表的大小,则抛出断言错误

  • 从列表中删除第一个值并返回。

    返回undefined | T

    第一个值,如果列表为空,则为undefined

    抛出异常

    如果不在写事务(write transaction)中,则抛出断言错误

  • 参数

    • Optional start : number
    • Optional end : number

    返回T []

    包含起始索引和结束索引之间元素的新数组。

    Array.prototype.slice()

    参数

    start - 从零开始的索引,从该位置开始提取。

    参数

    end - 从零开始的索引,从中结束提取。 它提取 end 以内但不包括的内容。

  • 创建collection的冻结快照。

    在原始collection中添加和删除的值不会反映在该方法返回的结果中,包括更改properties值以使其匹配或不匹配应用的任何筛选器的情况。

    不是深度快照。此快照中包含的 Realm 对象将随着对其进行的更改而继续更新,如果它们从 Realm 中删除,则它们将在相应索引处被null替换。

    返回结果< T >

    不会实时更新的结果。

  • 参数

    • predicate : ( ( value , index , array ) => unknown )
        • (索引数组 未知
        • 参数

          • T
          • index : number
          • array : readonly T []

          返回未知

    • Optional thisArg : any

    返回布尔值

    true 如果回调为任何collection元素返回真值;否则为false

    Array.prototype.some()

    参数

    predicate - 用于测试每个元素的函数。

    参数

    predicate.value — collection中正在处理的当前元素。

    参数

    predicate.index - 集合中正在处理的当前元素的索引。

    参数

    predicate.array — 调用了collectionevery

    参数

    thisArg - this关键字可以在谓词函数中引用的对象。 如果省略thisArg ,则将undefined用作this值。

  • 返回表示此collection的排序视图的新结果

    Realm 对象的集合可以根据这些对象的一个或多个属性进行排序,或者根据这些对象链接到的对象的属性进行排序。 要按单个属性排序,只需将该属性的名称传递给sorted() ,后面可以可选地加上一个布尔值,指示是否应反向排序。 对于多个属性,必须传递一组排序描述符,其中列出要排序的属性。

    其他类型的collection按值本身而不是属性的进行排序,因此不应提供属性名称或排序描述符。

    参数

    • Optional reverse : boolean

      按降序而不是升序排序。 如果descriptor是排序描述符数组,则可能无法应用。

    返回结果< T >

    根据传入的参数对结果进行排序。

    抛出异常

    如果指定的属性不存在,则出现错误。

  • 返回表示此collection的排序视图的新结果

    Realm 对象的集合可以根据这些对象的一个或多个属性进行排序,或者根据这些对象链接到的对象的属性进行排序。 要按单个属性排序,只需将该属性的名称传递给sorted() ,后面可以可选地加上一个布尔值,指示是否应反向排序。 对于多个属性,必须传递一组排序描述符,其中列出要排序的属性。

    其他类型的collection按值本身而不是属性的进行排序,因此不应提供属性名称或排序描述符。

    参数

    返回结果< T >

    根据传入的参数对结果进行排序。

    抛出异常

    如果指定的属性不存在,则出现错误。

  • 返回表示此collection的排序视图的新结果

    Realm 对象的集合可以根据这些对象的一个或多个属性进行排序,或者根据这些对象链接到的对象的属性进行排序。 要按单个属性排序,只需将该属性的名称传递给sorted() ,后面可以可选地加上一个布尔值,指示是否应反向排序。 对于多个属性,必须传递一组排序描述符,其中列出要排序的属性。

    其他类型的collection按值本身而不是属性的进行排序,因此不应提供属性名称或排序描述符。

    参数

    • 描述符字符串

      对collection进行排序的属性名称。

    • Optional reverse : boolean

    返回结果< T >

    根据传入的参数对结果进行排序。

    抛出异常

    如果指定的属性不存在,则出现错误。

  • 通过删除值和/或插入新值来更改列表内容。

    参数

    • start : number

      起始索引。 如果大于列表的长度,则将起始索引设置为该长度。 如果为负数,则起始索引将从列表末尾算起(例如 list.length - index )。

    • Optional deleteCount : number

      要从列表中删除的值的数量。 如果未提供,则删除从起始索引到列表末尾的所有值。

    返回T []

    包含已从列表中删除的值的数组。 如果未删除任何值,则数组为空。

  • 通过删除值和/或插入新值来更改列表内容。

    参数

    • start : number

      起始索引。 如果大于列表的长度,则将起始索引设置为该长度。 如果为负数,则起始索引将从列表末尾算起(例如 list.length - index )。

    • deleteCount : number

      要从列表中删除的值的数量。 如果未提供,则删除从起始索引到列表末尾的所有值。

    • Rest ...items : T []

      要插入到从index开始的列表中的值。

    返回T []

    包含已从列表中删除的值的数组。 如果未删除任何值,则数组为空。

  • 计算集合中值的总和或集合中所有对象中给定属性的总和,如果集合为空,则计算 0。

    仅支持 int、float 和 double 属性。 此方法完全忽略null值。

    参数

    • Optional 属性 : string

      对于collection的对象,要求和的属性。

    返回数字

    总和。

    抛出异常

    如果不存在具有该名称的属性或者属性不是数字,则出现错误。

  • 交换列表中两个索引元素的位置。

    参数

    • index1 : number

      第一个元素的索引。

    • index2 : number

      第二个元素的索引。

    返回void

    抛出异常

    如果不在写事务中,或者任何输入索引小于 0 或大于或等于列表的大小,则抛出断言错误

  • 将一个或多个值添加到列表的开头

    参数

    • Rest ...items : T []

      要添加到列表的值。

    返回数字

    添加值后列表的新长度。

    抛出异常

    如果值不是可以存储在列表中的类型,或者添加到列表的对象与列表的ObjectSchema不匹配,则抛出 {TypeError}。

    抛出异常

    如果不在写事务(write transaction)中,则抛出断言错误

使用TypeDoc生成