Closed acivang closed 9 years ago
Sorry that it's so hard to bootstrap Model all by itself. You can take a look at the Mongo adapter tests to see one way to get the adapter set up and working: https://github.com/geddy/model/blob/master/test/integration/adapters/mongo/index.js#L16
@mde thank u very much,i should see it,i will comment it later!
hello @mde ! I written code like that test flow:
var model = require('model');
var Foo = function () {
this.setAdapter('mongo', {
dbname:"itemDB"
});
this.defineProperties({
name: { type: 'string', required: true }
});
};
Foo = model.register('Foo', Foo);
var foo = Foo.create({"name":"aci test 2015"});
var adapter = Foo.getAdapter();
adapter.connect(function(){
foo.save();
});
it was worked! but,was it a bug?or was my code's error?
I think you were missing the step for actually creating and connecting the adapter in your previous code. I'm going to go ahead and close this issue -- if you continue to have problems, please feel free to reopen it!
when I run the code,it throw
throw code was:
the _db was null I debug model's code,it didn't execute connect function in adapters/mongo/index.js
and my mongodb module version is 2.0.18,and model module version is 6.0.1. How can i fix it? Thx!