Sails: ERROR: the `registerConnection` method must be renamed to `registerDatastore`

Created on 3 Jan 2017  路  1Comment  路  Source: balderdashy/sails

Sails version: 1.0.0-19
Node version: 4.2.6
NPM version: 4.0.5
Operating system: Ubuntu MATE 16.04 LTS



Following is the error

desk1@desk1-All-Series:~/git/LiveList$ sails console
info: Starting app in interactive mode...

error: A hook (`orm`) failed to load!
error:
error: Error: The adapter for datastore `default` is invalid: the `registerConnection` method must be renamed to `registerDatastore`.
    at /home/desk1/git/LiveList/node_modules/waterline/lib/waterline.js:196:15
    at /home/desk1/git/LiveList/node_modules/async/dist/async.js:3047:20
    at eachOfArrayLike (/home/desk1/git/LiveList/node_modules/async/dist/async.js:1002:13)
    at eachOf (/home/desk1/git/LiveList/node_modules/async/dist/async.js:1052:9)
    at Object.eachLimit (/home/desk1/git/LiveList/node_modules/async/dist/async.js:3111:7)
    at Object.initialize (/home/desk1/git/LiveList/node_modules/waterline/lib/waterline.js:190:11)
    at buildWaterlineOntology (/home/desk1/git/LiveList/node_modules/sails-hook-orm/lib/build-waterline-ontology.js:46:9)
    at async.auto._buildOntology (/home/desk1/git/LiveList/node_modules/sails-hook-orm/lib/initialize.js:572:7)
    at runTask (/home/desk1/git/LiveList/node_modules/async/dist/async.js:1660:17)
    at /home/desk1/git/LiveList/node_modules/async/dist/async.js:1602:17
    at processQueue (/home/desk1/git/LiveList/node_modules/async/dist/async.js:1612:17)
    at taskComplete (/home/desk1/git/LiveList/node_modules/async/dist/async.js:1630:13)
    at /home/desk1/git/LiveList/node_modules/async/dist/async.js:1653:21
    at /home/desk1/git/LiveList/node_modules/async/dist/async.js:339:31
    at /home/desk1/git/LiveList/node_modules/async/dist/async.js:847:20
    at async.auto._doubleCheckMigration (/home/desk1/git/LiveList/node_modules/sails-hook-orm/lib/initialize.js:488:16)
error: Could not load Sails app.
error:
error: Tips:
error:  芒垄 First, take a look at the error message above.
error:  芒垄脗聽Check that you're using the latest stable version of Sails.
error:  芒垄 Have a question or need help?  (http://sailsjs.com/support)

Datastores.js

module.exports.datastores = {
  //myPostgresql: {
  default: {
    adapter: require('sails-postgresql'),
    url: 'postgresql://nikz:[email protected]:5432/nikz'
  },
};

Models.js

module.exports.models = {
  //datastore: 'myPostgresql',
  migrate: 'alter',
  attributes: {
    createdAt: {
      type: 'number',
      autoCreatedAt: true,
    },
    updatedAt: {
      type: 'number',
      autoUpdatedAt: true,
    },
    id: {
      type: 'number',
      autoIncrement: true,
    },
  },
};

Package.json

{
  "name": "LiveList",
  "private": true,
  "version": "0.0.0",
  "description": "a Sails application",
  "keywords": [],
  "dependencies": {
    "async": "2.0.1",
    "grunt": "1.0.1",
    "lodash": "3.10.1",
    "sails": "^1.0.0-19",
    "sails-hook-grunt": "^1.0.4",
    "sails-hook-orm": "^2.0.0-0",
    "sails-hook-sockets": "^1.0.1",
    "sails-postgresql": "^0.11.4"
  },
  "scripts": {
    "start": "NODE_ENV=production node app.js",
    "test": "echo && echo \"* * * * * * * * * * * * * * * * * * * * * * * * * * * \" && echo \"About to run tests...\" && echo && if ! node ./node_modules/mocha/bin/mocha --timeout 10000 ; then echo && echo && echo \"- - -\" && echo \"Looks like something went wrong.\" && echo \"|  If you are not sure what to do next, try:\" && echo \"|  npm install mocha --save-dev\" && echo \"|  \" && echo \"|  And then:\" && echo \"|  mkdir test/\" && echo ; fi",
    "debug": "node debug app.js"
  },
  "main": "app.js",
  "repository": {
    "type": "git",
    "url": "git://github.com/desk1/LiveList.git"
  },
  "author": "desk1",
  "license": ""
}

I was not able to get any documentation relating datastore or this particular error. My DB is working proper and connections are all good. Also installed sails-postgresql module. Assume this is a bug inside the sails. Otherwise, please help me to fix this issue. Thank you.

To reproduce the error, add the adapter and url in datastores.js.

Most helpful comment

Error solved

  1. The version that is installed by npm install sails-postgresql@latest --save is v0.11.4. But this version only support Connection.js from sailsjs version below 0.12. To fix this , Install v1.0.0-1. Use the following command,

    npm install [email protected] --save

  2. Another issue i found was that I mistakenly deleted the 's' from 'defaults' in datastores.js. The corrected version is as follows:

module.exports.datastores = {
  defaults: {
    adapter: require('sails-postgresql'),
    url: 'postgresql://nikz:[email protected]:5432/nikz'
  },
};

>All comments

Error solved

  1. The version that is installed by npm install sails-postgresql@latest --save is v0.11.4. But this version only support Connection.js from sailsjs version below 0.12. To fix this , Install v1.0.0-1. Use the following command,

    npm install [email protected] --save

  2. Another issue i found was that I mistakenly deleted the 's' from 'defaults' in datastores.js. The corrected version is as follows:

module.exports.datastores = {
  defaults: {
    adapter: require('sails-postgresql'),
    url: 'postgresql://nikz:[email protected]:5432/nikz'
  },
};
Was this page helpful?
0 / 5 - 0 ratings