从交叉口删除第一个项目的动物
我有一个Fauna DB查询,该查询将返回一场比赛,因为字段的组合是唯一的:
await faunaClient.query(
Intersection(
Match(Index('tokens_search_by_blacklisted'), false),
Match(Index('tokens_search_by_token'), refreshToken),
Match(Index('tokens_search_by_type'), tokenTypes.REFRESH)
)
)
我想知道的是从这里删除我的第一个项目,我知道我可以分页,lambda delete,但我不删除。想迭代。我只想删除返回的第一个值。
我知道,如果您使用它,它将从集合中获取第一项,但可悲的是,删除不执行此操作,我不必让对象aka执行读取只是为了选择ref然后删除。
I have a fauna db query that will return one match due to the combination of fields being unique:
await faunaClient.query(
Intersection(
Match(Index('tokens_search_by_blacklisted'), false),
Match(Index('tokens_search_by_token'), refreshToken),
Match(Index('tokens_search_by_type'), tokenTypes.REFRESH)
)
)
What I want to know is from here how can I delete the first item returned, I know theoretically I can paginate, lambda delete but I don't want to iterate. I would just like to delete the first value returned.
I know if you use Get it will get the first item from a set but sadly delete doesn't do this and I shouldn't have to get the object aka perform a read just to select the ref then delete.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您使用
匹配
时,结果是索引支持集的集合参考。这样的集合包括对涵盖文档的引用,即使索引未明确指定ref
字段中的values
定义。一旦您使用
交叉点
,union
或差异
,结果集仅包括在索引的values
中定义的字段定义:隐式ref
字段丢失。在Fauna中,集合是无界的,因此没有任何具体项目可以操作,直到通过
paginate
或get
实现该集合为止。因此,您需要使用其中一个功能才能从交叉路口检索元组。您可以将页面大小设置为1,以便
paginate
仅返回一个项目。Paginate
的实现一旦有一个充满结果的页面,就会返回,因此其性能非常好。您需要确保
交集中的元素
结果包括对DELETE的文档引用,否则您将无法删除。When you use
Match
, the result is a set reference for an index-backed set. Such sets include a reference to the covered document, even if the index doesn't explicitly specify theref
field in thevalues
definition.Once you use
Intersection
,Union
, orDifference
, the resulting set only includes the fields defined in an index'svalues
definition: the implicitref
field is lost.In Fauna, sets are unbounded, so there aren't any concrete items to operate on until the set is materialized via
Paginate
orGet
. So, you'll need to use one of those functions in order to retrieve the tuples from the intersection.You can set the page size to 1 so that
Paginate
only returns one item.Paginate
's implementation returns as soon as it has a page full of results, so it performs pretty well.You'll need to be sure that the tuples in the
Intersection
result includes the document reference to delete, or you won't be able to delete.