feathersjs-ecosystem / feathers-knex

Service adapters for KnexJS a query builder for PostgreSQL, MySQL, MariaDB, Oracle and SQLite3
MIT License
112 stars 59 forks source link

README example does not work #18

Closed dbkaplun closed 8 years ago

dbkaplun commented 8 years ago
var feathers = require('feathers');
var hooks = require('feathers-hooks');
var knex = require('feathers-knex');

// Initialize a MongoDB service with the users collection on a local MongoDB instance
var app = feathers()
  .configure(hooks())
  .use('/users', knex('users', {
    dialect: 'sqlite3',
    connection: {
      filename: './data.db'
    }
  }));

app.lookup('users').before({
  create: function(hook, next) {
    hook.data.createdAt = new Date();
    next();
  },

  update: function(hook, next) {
    hook.data.updatedAt = new Date();
    next();
  }
});

app.listen(8080);

Output:

TypeError: app.lookup is not a function
    at Object.<anonymous> (/Users/dan.kaplun/euclidsnap/server.js:15:5)
    at Module._compile (module.js:425:26)
    at Object.Module._extensions..js (module.js:432:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Function.Module.runMain (module.js:457:10)
    at startup (node.js:136:18)
    at node.js:972:3
daffl commented 8 years ago

It's app.service not app.lookup, I fixed it in the readme. Sorry about that, we're still in the process reviewing all the adapter docs and making sure everything works as described (.lookup was the pre Feathers 1.0 name for .service).

dbkaplun commented 8 years ago

I understand. I think the feathers-knex adapter is your most important adapter. Keep up the good work!!

daffl commented 8 years ago

Thanks and that's good to know. Let us know if you run into any other issues.