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" });
},
});
}