Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

203
Vistas
Select the table according to the category, topic and microtopic using just one model Node.Js

I have several tables that have the same structure, they all have a title, description, topic and microtopic but they have different content. I want to display the table information according to the page I am using a single Model.

On this site I will have a page with several categories such as: Movies, music and series. Each category will have a topic, for example, Movies will have: Action, horror, adventure. And each topic will have a microtopic, for example the Film category that has the Action topic will have the following microtopics: Old, current, future releases. And within each microtopic you will have a list containing movies with their title, description, topic and microtopic corresponding to that search.

I would like to know how I could carry out this process. I have here an example of a model that I created and what I imagined would be to change the tableName according to the url but I didn't find a way to do that.

I leave here the example of the model I created:

import {Model, DataTypes} from 'sequelize';
import {sequelize} from '../instances/mysql';

export interface ContentInstance extends Model{
    id: number,
    title: string,
    description: string,
    topic: string,
    microtopic: string,
};

export const Content= sequelize.define<ContentInstance>("Content", {
    id:{
        primaryKey: true,
        autoIncrement: true,
        type: DataTypes.INTEGER
    },
    title:{
        type: DataTypes.STRING,
    }, 
    description:{
        type: DataTypes.STRING,
    },
    topic:{
        type: DataTypes.STRING
    },
    microtopic:{
        type: DataTypes.STRING
    }   

}, {
    tableName: 'actionold', //I imagined something like concatenating topic + microtopic but dinamically
    timestamps: false
});

I'm new to backend and Node.Js (and I'm using mySQL)

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda