mirror of
https://github.com/typicode/json-server.git
synced 2025-07-30 13:42:11 +08:00
Foreign key suffix (#570)
This commit is contained in:
@ -64,7 +64,7 @@ module.exports = function () {
|
||||
default: 'id'
|
||||
},
|
||||
foreignKeySuffix: {
|
||||
alias: 'f',
|
||||
alias: 'fks',
|
||||
description: 'Set foreign key suffix, (e.g. _id as in post_id)',
|
||||
default: 'Id'
|
||||
},
|
||||
|
@ -40,10 +40,11 @@ function createApp (source, object, routes, middlewares, argv) {
|
||||
|
||||
let router
|
||||
|
||||
const { foreignKeySuffix } = argv
|
||||
try {
|
||||
router = jsonServer.router(
|
||||
is.JSON(source) ? source : object,
|
||||
argv
|
||||
foreignKeySuffix ? { foreignKeySuffix } : undefined
|
||||
)
|
||||
} catch (e) {
|
||||
console.log()
|
||||
|
Reference in New Issue
Block a user