Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

328
Views
Mangosta: compruebe si el valor existe en la matriz de cadenas

Estoy consultando para obtener todos los artículos que tienen un nombre de fuente y una categoría específicos.

Tengo un esquema de artículo que se ve a continuación.

El problema al que me enfrento es que obtiene los artículos con el nombre de fuente correcto, pero no busca la categoría correcta. Por ejemplo, si la fuente es "cnn" y la categoría es "deportes", obtiene todos los artículos de CNN correctamente, pero no con las categorías correctas (los artículos pueden tener categorías de ['política', 'cultura'] sin deportes)

 const article_schema = new mongoose.Schema({ title: { type: String, required: true }, thumbnail_url: { type: String, required: true }, summary: { type: String, required: true }, text: { type: String, required: true }, link: { type: String, required: true }, publish_date: { type: String, required: true }, source: { name: { type: String, required: true }, name_slug: { type: String, required: true }, link: { type: String, required: true }, display_picture_url: { type: String, required: true }, biography: { type: String, required: true }, tags: { type: [String], required: true }, rssFeeds: [{ url: { type: String, required: true }, categories: { type: [String], required: true } }] } });
 let getNews = async (req, res) => { const { sort, filter, current_page, limit, category_slug } = req.body; let articles = await Article.findOne({ 'source.name_slug': filter, categories: category_slug }); res.setHeader('Content-Type', 'application/json'); res.status(200).send({ articles }); }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!