Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example section #2

Open
ArnaudCourbiere opened this issue Jan 18, 2014 · 7 comments
Open

Add example section #2

ArnaudCourbiere opened this issue Jan 18, 2014 · 7 comments
Assignees

Comments

@ArnaudCourbiere
Copy link
Owner

No description provided.

@ghost ghost assigned ArnaudCourbiere Jan 18, 2014
@freew01f
Copy link

Thanks for you work~
It's really help me~

@ArnaudCourbiere
Copy link
Owner Author

You're welcome, I need to get back on it and add support for the remaining functionalities.

@dlaxar
Copy link

dlaxar commented Jun 1, 2014

Hi,

I'd be happy to help you build an example section because unfortunately I'm currently struggling to get somewhere.

var data = yield thunkify(collection.find({name: 'test'}).toArray)();

This can't really be it?

@ArnaudCourbiere
Copy link
Owner Author

Hey,

That would be great! If I guess right what you are trying to do it would be:
(I can't run it right now but it should work)

var comongo = require('co-mongodb');

co(function *() {
  var db = yield comongo.client.connect('mongodb://localhost:27017/test');
  var collection = yield comongo.db.collection(db, 'testCollection');
  var cursor = yield comongo.collection.find(collection, { name: 'test });
  var data = cursor.toArray();
})();

More documentation is definitely needed, plus finishing the unit tests and support for the rest of the native driver features.

@dlaxar
Copy link

dlaxar commented Jun 3, 2014

Sure, just ping me whenever you've got time so we can dig into the examples.

Btw: does not work ;) - toArray() complains that a callback is mandatory. However, you've pointed me into the right direction

This is code that works:

// either
// var cursor = yield mongo.collection.find(collection, {name: 'test'});
// or
var cursor = collection.find({name: 'test'}); // note: no yield!!!

// and finally (for both cases)
var data = yield mongo.cursor.toArray(cursor);

Again: whenever you need help let me know (email or whatever you like). I'd be happy to help. One more thing: I find it quite difficult to use this package because it's interface isn't consistent with the native drive nor within itself (see example above ;)). Maybe that's why it is so difficult to write documentation/tests.

@ArnaudCourbiere
Copy link
Owner Author

Will do. Probably over the weekend.

@ArnaudCourbiere
Copy link
Owner Author

Hey, I got caught up this weekend. Meanwhile, you can look at the test folder to see some examples and try to write your own tests to experiment.

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

No branches or pull requests

3 participants