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

188
Visualizações
Where can I find the use of Model.deleteOne in the official API documentation?

The API documentation is found here, however there are two entries:

Model.deleteOne

and

Model.prototype.deleteOne

both of which do not appear to use the form I am using as I am explicitly using the form below, while the docs use it as a place holder for such things as Character or product.

const Model = mongoose.model(name, schema);
Model.deleteOne()

My delete is working fine but I want to read the actual documentation for my function.

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

0

If I specify nothing then nothing happens. In fact not a lot useful happens ....UnhandledPromiseRejectionWarning: MongoServerError: BSON field 'delete.deletes.q' is missing but a required field.

So we must use the param filter and provide a doc to filter and delete:

(method) Collection<Document>.deleteOne(filter: Filter<Document>): Promise<DeleteResult> (+3 overloads)
Delete a document from a collection

@param filter — The filter used to select the document to remove

@param options — Optional settings for the command

@param callback — An optional callback, a Promise will be returned if none

So like so like the defintion says Collection<Document>.deleteOne({_id: 12345})

OR

delete = (x) => { if(x) db.collection.deleteOne({_id: x});
    return 'you must provide a value to delete for field _id';
    }

Are you sure your method deletes one or more docs without a filter?

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