Search code examples
mongodbsails.jsnativesails-mongo

cant use .native function in sails mongo


I've been working around some ways to use .native() to do a simple aggregation function in sails with mongo.

Already following the steps to install dependencies. (http://sailsjs.org/documentation/reference/waterline-orm/models/native)

But still it returns me this error : .native is not a function

Did I missed something ?


Solution

  • You may be using the wrong adapter. You can check this in your models.js in the connection key. It might be commented out, if it is, it's going to connect to to local disk. Check that in connections.js, the name of your object that has mongodb config is named the same as models.js. eg.

    connections.js

    mongoServer: {
    adapter: 'sails-mongo',
    host: 'localhost',
    port: 27017,
    database: 'dbname'
    

    }

    models.js

    connection: 'mongoServer'