Skip to content
This repository has been archived by the owner on Feb 10, 2022. It is now read-only.

Error occured while fetch all records #32

Closed
asci opened this issue Apr 3, 2015 · 10 comments
Closed

Error occured while fetch all records #32

asci opened this issue Apr 3, 2015 · 10 comments

Comments

@asci
Copy link

asci commented Apr 3, 2015

on start I get this error:

[Error: Module did not self-register.]
js-bson: Failed to load c++ bson extension, using pure JS version

and when I try to yield SomeModel.all();
this error throws:

TypeError: Cannot read property 'find' of undefined
      at Query.find (/Users/artem/Projects/elastic/metagen/node_modules/mongorito/lib/query.js:127:37)
      at GeneratorFunctionPrototype.next (native)

My model looks like

var Mongorito = require('mongorito');
var Model = Mongorito.Model;
Mongorito.connect('mongodb://localhost:27017/mydb');

var Api = Model.extend({
    collection: function () {
        return 'apis';
    }
});

module.exports = Api;

I'm using Koajs and iojs

@vadimdemedes
Copy link
Owner

Does this error occur when using .find() or any other query methods?

@vadimdemedes
Copy link
Owner

It is also weird that you are getting this error, because I have this covered in tests and tests run ok (https://github.com/vdemedes/mongorito/blob/master/test/mongorito.test.js#L258).

@asci
Copy link
Author

asci commented Apr 3, 2015

Yes, it occurs with find. Maybe it because in NPM mongorito v1.0.0 ?

@vadimdemedes
Copy link
Owner

Run npm rebuild to fix the following error:

[Error: Module did not self-register.]
js-bson: Failed to load c++ bson extension, using pure JS version

@vadimdemedes
Copy link
Owner

Mongorito depends on some modules, that need to be compiled. When you switch Node.js/io.js version without npm rebuild, this error will appear.

@vadimdemedes
Copy link
Owner

Error reproduced, figuring out how to fix it, thanks for reporting!

@vadimdemedes
Copy link
Owner

Found a cause. It is because of .extend() way of defining your models. If you'll use ES6 classes, it should be fine. Meanwhile, I am trying to fix .extend() now.

@vadimdemedes
Copy link
Owner

Fixed and available on npm as mongorito@1.1.1.

@asci
Copy link
Author

asci commented Apr 3, 2015

Thanks, that was really fast:)
btw, it is not my busy, but removing this way of defining model till even iojs doesn't have it without flag — not good)

@vadimdemedes
Copy link
Owner

Who said I removed .extend()? :D It's still there, but rewritten and working as expected! You can go back to defining models with .extend() now, but I strongly encourage you to switch to ES6 classes.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants