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

106
Visualizações
Pulling Random Documents by ID using JS

I have 100 documents in a Cloudant DB with IDs from 1-100. I am trying to pull the first 50 documents at random using js.

For example, the query would pull document #47 then repeat and pull #21 so on and so forth.

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

0

You can't randomize the output of a Cloudant index on the server side -- documents are returned in lexicographical order on either the emitted key in the case of a secondary index, or the document id in the case of the primary index. If you know the range of your document ids, you can of course fetch them in any order you like using a POST to the _all_docs endpoint with a json body containing a "keys" array. But you'd need to generate this array client-side first. How to shuffle an array in javascript is well documented on this site and others.

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