One fibjs wrapper for knex
, which is designed for NodeJS
and Browser
.
There's no built-in knex
in this package's dependencies, for purpose that you can use any valid version knex
as you like
knex
@>= 0.14 < 0.17
if use typescript, install types to enable typo lint:
@types/node
You can get Wrapped Knex safely like this:
const FKenx = require('@fxjs/knex')
assert.property(FKenx, 'SandBox')
Distinguished with the original knex
package, fibjs version one has more properties:
SandBox
: one SandBox class extended from vm.SandBox, which has required modules on whichknex
run in fibjs;
There's only necessary modules for knex
in built-in sandbox
, you can customized your own sandbox by create one SandBox
instance. Just use FKenx.SandBox
as fibjs's built-in vm.SandBox
like this:
const FKenx = require('@fxjs/knex')
const vbox = new FKenx.SandBox(
// modules
{
a: AMOD,
b: BMOD,
// useless, it's reserved module
uuid: require('uuid')
},
// optional, fallback function
(name) => require(name),
// optional, global object
{
// ...
}
)
All reserved modules would NOT been overwritten by the ones user passing, they are:
fs
path
os
url
tty
util
events
assert
crypto
uuid
Copyright (c) 2018-present, Richard