Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

160
Visualizações
Fauna delete first item from intersection

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.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

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 the ref field in the values definition.

Once you use Intersection, Union, or Difference, the resulting set only includes the fields defined in an index's values definition: the implicit ref 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 or Get. 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.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda