pgte / alfred

Node is your mansion, Alfred is your butler. Node.js key-value store
http://pgte.github.com/alfred/
MIT License
149 stars 10 forks source link

database has no method 'ensure' #1

Closed mhayashi closed 13 years ago

mhayashi commented 13 years ago

Hi,

I've encoutered this error when I called db.define().

$ node user.js 

/Users/masahiro/.node_libraries/.npm/step/0.0.4/package/lib/step.js:38
        throw arguments[0];
                       ^
TypeError: Object [object Object] has no method 'ensure'
    at /Users/masahiro/.node_libraries/.npm/alfred/0.5.2b3/package/lib/alfred/meta/model/model.js:26:14
    at /Users/masahiro/.node_libraries/.npm/alfred/0.5.2b3/package/lib/alfred/util/promise.js:6:3
    at new <anonymous> (/Users/masahiro/.node_libraries/.npm/alfred/0.5.2b3/package/lib/alfred/meta/model/model.js:25:22)
    at Object.define (/Users/masahiro/.node_libraries/.npm/alfred/0.5.2b3/package/lib/alfred/meta/model/model.js:63:10)
    at [object Object].define (/Users/masahiro/.node_libraries/.npm/alfred/0.5.2b3/package/lib/alfred/meta/database.js:446:16)
    at /Users/masahiro/projects/node/dev/alfred/user.js:5:17
    at Function.finalize (/Users/masahiro/.node_libraries/.npm/alfred/0.5.2b3/package/lib/alfred/meta/database.js:169:7)
    at next (/Users/masahiro/.node_libraries/.npm/step/0.0.4/package/lib/step.js:51:23)

What am I missing?

Source code:

var alfred = require('alfred');

alfred.open('./user.db', function(err, db) {
  if (err) throw err;
  var User = db.define('User');
  User.property('username', 'string');
  User.property('password', 'string');
});
pgte commented 13 years ago

The base problem should be that your './user.db' path must exist and be a directory (as it says on the API docs).

But I'll keep this one around so it yields a convenient error.

mhayashi commented 13 years ago

Oh... I'm ashamed of myself. I used a file because I just switched node-dirty to Alfred. I leave you to close this. Thanks.

pgte commented 13 years ago

:)

pgte commented 13 years ago

Closing