Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Calculadora

0

46
Vistas
In the mocking library miragejs is there a way to change the id that mirage auto assigns to be called e.g. "product_id", and not "id"?

The following function, makeServer should successfully seed the mirage database such that console.log(server.db.dump()); will return { id: '1', name: 'Test Product' }.

a) is there a way to change the default name of "id" mirage uses for a given model to something else, e.g. "product_id"? (In e.g. postgresQL the id column does not need to be called "id"). b) if there is, is this a bad idea for some reason?

I have read the 'db', 'model', and 'server' sections of the API docs and haven't been able to find this. At the moment I am passing the data around with "product_id" and if I can't alter mirage I will have to alter that in order that it will return product entries that the requests it is intercepting will accept.

import { createServer, Model } from "miragejs";

export function makeServer({ environment = "test" }) {
  return createServer({
    environment,

    models: {
      product: Model,
    },

    seeds(server) {
      server.create("product", { name: "Test Product" });
    },
  });
}
7 months 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 empleo Planes Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2023 PeakU Inc. All Rights Reserved.