Skip to content
This repository was archived by the owner on Nov 19, 2022. It is now read-only.

fxjs-modules/knex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fibjs Wrapper For Knexjs

NPM version Build Status Build status

Introduction

One fibjs wrapper for knex, which is designed for NodeJS and Browser.

Pre-requisite

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

APIs

cjs: Wrapped Knex

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 which knex run in fibjs;

Use FKenx.SandBox to customized your own SandBox

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

LICENSE

MIT

Copyright (c) 2018-present, Richard

About

fibjs wrapper & helper of knexjs

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors