hapipal / schwifty

A model layer for hapi integrating Objection ORM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No knexfile?

alexisohayon opened this issue · comments

Hi!

I'm new to Hapi and try to setup a new project with knex & objection, this plugin seems to be really cool but I'm probably missing something: is it me or you don't need the generated knexfile to specify all the config informations? I prefer to use it as it's the original knex stuff and I find it reassuring :)

Can you enlight me?

Thanks!

Ok, sorry, I found the answer by digging a bit more. You can close the issue! ;)

Hey there! It's true that you don't need to use a knexfile with schwifty. But you certainly can use one! Here's an objection/schwifty boilerplate that pull knex config into knexfile.js from the server config (see server/manifest.js) https://github.com/devinivy/boilerplate-api/tree/flavor-objection.

You can also go the other way, which is what it sounds like you might want to do: write a knexfile exactly how you like it. Then when you register schwifty just set schwifty's knex option to knex: require('path/to/your/knexfile'). If you use a knexfile with per-environment configs it would look more like, knex: require('path/to/your/knexfile')[process.env.NODE_ENV].

Let us know how it goes!

Ah, sounds good :)