caminte icon indicating copy to clipboard operation
caminte copied to clipboard

MongoDB: Model::query not defined for this adapter

Open GerkinDev opened this issue 7 years ago • 4 comments

Hi, I'm trying to use Caminte to execute raw MongoDB query, but I can't find a way to do so. I've tried to use the query method, as described for other adapters, but it fails with following error:

Error: Model::query not defined for this adapter at Function.AbstractClass.query (.../node_modules/caminte/lib/abstract-class.js:216:18)

How can I execute my aggregate statement?

Thank you

GerkinDev avatar Aug 25 '17 12:08 GerkinDev

In model you can use schema. Eg for aggregate:

schema
    .adapter
    .collection(modelName)
    .aggregate()

kmlwlkwk avatar Aug 25 '17 12:08 kmlwlkwk

Thank you for your quick reply. I've tried the following, but it is still not working.

const caminte = require( 'caminte' );
const Schema = caminte.Schema;
const config = {
	driver:   'mongo',
	host:     'mongo',
	port:     '27017',
	database: 'test',
};
const schema = new Schema( config.driver, config );

schema.adapter.collection('times'); // Undefined method
schema.adapter.collections; // Empty object

GerkinDev avatar Aug 25 '17 12:08 GerkinDev

It's not connected with db yet

Z pozdrowieniami, Kamil W**alkowiak tel. +48 792 178 330 | http://cdev.pl http://cdev.pl

2017-08-25 14:21 GMT+02:00 Gerkin [email protected]:

Thank you for your quick reply. I've tried the following, but it is still not working.

const caminte = require( 'caminte' );const Schema = caminte.Schema;const config = { driver: 'mongo', host: 'mongo', port: '27017', database: 'test', };const schema = new Schema( config.driver, config ); schema.adapter.collection('times'); // Undefined methodschema.adapter.collections; // Empty object

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/biggora/caminte/issues/163#issuecomment-324903584, or mute the thread https://github.com/notifications/unsubscribe-auth/AELqvnABPv-Lxm8hKSefNFEmWz46OeLiks5sbrxZgaJpZM4PCk63 .

kmlwlkwk avatar Aug 25 '17 13:08 kmlwlkwk

And, just a silly question, how am I supposed to execute a callback once the connection is done ? I can't find it in the documentation

GerkinDev avatar Aug 25 '17 14:08 GerkinDev