可能在 Firebase 上查询 !equalTo: null 吗?
Is possible query an !equalTo: null on Firebase?
我正在使用此查询来验证我的 Firebase 上是否存在数据(使用 AngularFire2)
let aux = this.afData.list("/drivers", { query: { orderByChild: '/accountHistory/approved', equalTo: null } });
工作得很好,但我还需要进行反向查询。
像这样
let aux = this.afData.list("/drivers", { query: { orderByChild: '/accountHistory/approved', equalTo: !null } });
问题是。第二个查询,只有 returns 如果值为 TRUE,我将在 /driveruid/accountHistory/approved'
上存储时间戳
有什么方法可以只验证值是否存在?
谢谢!
在 Firebase 文档中,使用 orderByChild
return 的查询按以下顺序列出:-
Children with a null value for the specified child key come first.
Children with a value of false for the specified child key come next. If multiple children have a value of false, they are sorted lexicographically by key.
Children with a value of true for the specified child key come next. If multiple children have a value of true, they are sorted lexicographically by key.
Children with a numeric value come next, sorted in ascending order. If multiple children have the same numerical value for the specified child node, they are sorted by key.
Strings come after numbers and are sorted lexicographically in ascending order. If multiple children have the same value for the specified child node, they are ordered lexicographically by key.
Objects come last and are sorted lexicographically by key in ascending order.
虽然您的第一个查询工作正常,但对于您的第二个查询,您可以尝试以下代码。
let aux = this.afData.list("/drivers", { query: { orderByChild: '/accountHistory/approved', startAt: false });
通过这样做,您的查询结果将不会包含您的子节点的值为 null
的数据。
不过,我建议您确保所有节点的子节点上的数据都是同一类型,以尽量减少 Class 转换异常和其他错误的可能性。这更像是一个 hack。
我正在使用此查询来验证我的 Firebase 上是否存在数据(使用 AngularFire2)
let aux = this.afData.list("/drivers", { query: { orderByChild: '/accountHistory/approved', equalTo: null } });
工作得很好,但我还需要进行反向查询。
像这样
let aux = this.afData.list("/drivers", { query: { orderByChild: '/accountHistory/approved', equalTo: !null } });
问题是。第二个查询,只有 returns 如果值为 TRUE,我将在 /driveruid/accountHistory/approved'
上存储时间戳有什么方法可以只验证值是否存在?
谢谢!
在 Firebase 文档中,使用 orderByChild
return 的查询按以下顺序列出:-
Children with a null value for the specified child key come first.
Children with a value of false for the specified child key come next. If multiple children have a value of false, they are sorted lexicographically by key.
Children with a value of true for the specified child key come next. If multiple children have a value of true, they are sorted lexicographically by key.
Children with a numeric value come next, sorted in ascending order. If multiple children have the same numerical value for the specified child node, they are sorted by key.
Strings come after numbers and are sorted lexicographically in ascending order. If multiple children have the same value for the specified child node, they are ordered lexicographically by key.
Objects come last and are sorted lexicographically by key in ascending order.
虽然您的第一个查询工作正常,但对于您的第二个查询,您可以尝试以下代码。
let aux = this.afData.list("/drivers", { query: { orderByChild: '/accountHistory/approved', startAt: false });
通过这样做,您的查询结果将不会包含您的子节点的值为 null
的数据。
不过,我建议您确保所有节点的子节点上的数据都是同一类型,以尽量减少 Class 转换异常和其他错误的可能性。这更像是一个 hack。