{"id":42747,"library":"feathers-knex","title":"feathers-knex","description":"A database adapter for Feathers.js that provides a service wrapper around KnexJS, a SQL query builder supporting PostgreSQL, MySQL, SQLite3, MSSQL, MariaDB, and Oracle. Current stable version 8.0.1. This package implements the Feathers Common database adapter API and querying syntax, offering features like pagination, multi-record operations, custom events, and parameterized queries. It requires both `knex` and the corresponding database driver. Released under the Feathers ecosystem, it follows semantic versioning and is actively maintained.","status":"active","version":"8.0.1","language":"javascript","source_language":"en","source_url":"git://github.com/feathersjs-ecosystem/feathers-knex","tags":["javascript","feathers","feathers-plugin","typescript"],"install":[{"cmd":"npm install feathers-knex","lang":"bash","label":"npm"},{"cmd":"yarn add feathers-knex","lang":"bash","label":"yarn"},{"cmd":"pnpm add feathers-knex","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required peer dependency; the knex instance is passed as the Model option.","package":"knex","optional":false},{"reason":"Database driver for MySQL; install only if using MySQL.","package":"mysql","optional":true},{"reason":"Database driver for PostgreSQL; install only if using PostgreSQL.","package":"pg","optional":true},{"reason":"Database driver for SQLite; install only if using SQLite.","package":"sqlite3","optional":true}],"imports":[{"note":"CJS require works for Node, but ESM import is preferred for modern projects.","wrong":"const service = require('feathers-knex');","symbol":"default","correct":"import service from 'feathers-knex';"},{"note":"Named export available as an alternative to default.","wrong":"","symbol":"service (named)","correct":"import { service } from 'feathers-knex';"},{"note":"For TypeScript projects, you can import the Service type for type annotations.","wrong":"","symbol":"TypeScript types","correct":"import type { Service } from 'feathers-knex';"}],"quickstart":{"code":"import express from '@feathersjs/express';\nimport feathers from '@feathersjs/feathers';\nimport knex from 'knex';\nimport service from 'feathers-knex';\n\nconst app = express(feathers());\n\nconst db = knex({\n  client: 'sqlite3',\n  connection: {\n    filename: './db.sqlite'\n  }\n});\n\nawait db.schema.createTable('messages', table => {\n  table.increments('id');\n  table.string('text');\n});\n\napp.use('/messages', service({\n  Model: db,\n  name: 'messages'\n}));\n\napp.listen(3030).then(() => console.log('Feathers server started on port 3030'));","lang":"typescript","description":"Creates a Feathers app with a Knex-backed messages service using SQLite."},"warnings":[{"fix":"Use Node >= 12 and switch to ES module imports or use dynamic import for CJS projects.","message":"Version 8.0.0 dropped support for Node < 12 and changed the export to ESM-only.","severity":"breaking","affected_versions":">=8.0.0"},{"fix":"Refactor code to use `service.find({ query: { ... } })` directly.","message":"The `adapter.createQuery` method is deprecated; use `service.find` with query instead.","severity":"deprecated","affected_versions":">=7.0.0"},{"fix":"Set `multi: true` in the service options to allow batch creation.","message":"If `multi: true` is not set, `create` with an array will fail silently or throw an error.","severity":"gotcha","affected_versions":">=6.0.0"},{"fix":"Add `'$search'` to the `whitelist` array in service options.","message":"Using `$search` in queries requires the `whitelist` option to include `$search`.","severity":"gotcha","affected_versions":">=5.0.0"}],"env_vars":null,"search_vec":"'8.0.1':31 'activ':77 'adapt':6,39 'api':40 'around':14 'builder':19 'common':37 'correspond':63 'current':28 'custom':52 'databas':5,38,64 'driver':65 'ecosystem':70 'event':53 'feather':2,36,69,80,82 'feathers-knex':1 'feathers-plugin':81 'feathers.js':8 'featur':45 'follow':72 'implement':34 'javascript':79 'knex':3,60 'knexj':15 'like':46 'maintain':78 'mariadb':25 'mssql':24 'multi':49 'multi-record':48 'mysql':22 'offer':44 'oper':51 'oracl':27 'packag':33 'pagin':47 'parameter':55 'plugin':83 'postgresql':21 'provid':10 'queri':18,42,56 'record':50 'releas':66 'requir':58 'semant':73 'servic':12 'sql':17 'sqlite3':23 'stabl':29 'support':20 'syntax':43 'typescript':84 'version':30,74 'wrapper':13","created_at":"2026-06-05T16:56:28.009716+00:00","updated_at":"2026-06-05T16:56:28.009716+00:00","problems":[{"fix":"Use `import knex from 'knex';` (default import) instead of `import { knex } from 'knex';`.","cause":"Knex package is not a constructor when imported incorrectly in ESM.","error":"TypeError: knex is not a function"},{"fix":"Run `npm install knex` in your project.","cause":"Knex is not installed as a dependency.","error":"Error: Cannot find module 'knex'"},{"fix":"Create the table using `db.schema.createTable('messages', ...)` before using the service.","cause":"The database table does not exist; schema not created.","error":"Error: insert into `messages` (`text`) values (?) - SQLITE_ERROR: no such table: messages"},{"fix":"Use `import service from 'feathers-knex';` or `const service = require('feathers-knex');`.","cause":"Using the wrong import style; default export is a function, not an object.","error":"TypeError: service is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/feathersjs-ecosystem/feathers-knex","github":"git://github.com/feathersjs-ecosystem/feathers-knex","docs":null,"changelog":null,"pypi":null,"npm":"feathers-knex","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}