javascript - Sails 1 - 违反一致性 : Attempting to tear down a datastore (`default` ) which is not currently registered with this adapter

标签 javascript model sails.js datastore sails-mongo

我在 lifting a sails 1 应用程序时遇到以下错误:

Consistency violation: Attempting to tear down a datastore (default) which is not currently registered with this adapter. This is usually due to a race condition in userland code (e.g. attempting to tear down the same ORM instance more than once), or it could be due to a bug in this adapter.

我完全不知道这个错误是什么意思。这是我的配置文件的样子:

Category.js(模型)

module.exports = {
    schema: true,
    attributes: {
        name: {
            type: 'string',
            required: true,
            unique: true
        },
        products: {
            collection: 'product',
            via: 'category'
        },
        parentCategory: {
            model: 'category',
            defaultsTo: null
        },
        ancestors: {
            type: 'json',
            columnType: 'array',
            defaultsTo: []
        }
    }
};

datastores.js

module.exports.datastores = {
default: {

    adapter: require('sails-mongo'),
    host: 'localhost',
    port: 27017,
    // user: 'username',
    // password: 'password',
    database: 'your_mongo_db_name_here'

}


};

package.json

{
    "name": "mag",
    "private": true,
    "version": "2.0.0",
    "description": "site admin with modules",
    "keywords": [],
    "dependencies": {
        "@uirouter/angularjs": "^1.0.5",
        "angular": "^1.6.5",
        "angular-cookies": "^1.6.5",
        "angular-sanitize": "^1.6.5",
        "angular-ui-bootstrap": "^2.5.0",
        "async": "2.0.1",
        "babel-cli": "^6.24.1",
        "babel-core": "^6.25.0",
        "babel-loader": "^7.1.1",
        "babel-preset-es2015": "^6.24.1",
        "bcrypt": "^0.8.7",
        "bootstrap": "^3.3.7",
        "bootstrap-loader": "^2.1.0",
        "fs-extra": "^0.30.0",
        "imports-loader": "^0.7.1",
        "jquery": "1.11.0",
        "jsonwebtoken": "^5.5.4",
        "lodash": "3.10.1",
        "ng-lodash": "^0.2.3",
        "ng-toast": "^2.0.0",
        "resolve-url-loader": "^2.1.0",
        "sails": "^1.0.0-36",
        "sails-disk": "^0.10.10",
        "sails-hook-babel": "^6.0.3",
        "sails-hook-orm": "^2.0.0-0",
        "sails-hook-sockets": "^1.0.1",
        "sails-mongo": "^1.0.0-9",
        "style-loader": "^0.18.2",
        "url-loader": "^0.5.9",
        "webpack": "2.2.1"
    },
    "devDependencies": {
        "babel-preset-env": "^1.6.0",
        "clean-webpack-plugin": "0.1.16",
        "copy-webpack-plugin": "4.0.1",
        "css-loader": "^0.27.3",
        "ejs-loader": "0.3.0",
        "extract-text-webpack-plugin": "2.1.0",
        "less": "2.7.2",
        "less-loader": "4.0.1",
        "sails.io.js": "1.1.9",
        "socket.io-client": "1.7.3"
    },
    "scripts": {
        "start": "NODE_ENV=production node app.js"
    },
    "main": "app.js",
    "author": "",
    "license": ""
}

有什么提示吗??

最佳答案

出现此错误是因为在我的 User.js 模型中,我引用了一个我在尝试升起我的风 sails 应用程序时尚未创建的后期收集模型

帖子:{ 集合:'发布', 通过:“所有者” },

通过注释掉问题解决了。显然,出现此错误的可能原因有很多。最好仔细查看整个堆栈跟踪 - 那是我发现错误的地方。希望这会有所帮助。

关于javascript - Sails 1 - 违反一致性 : Attempting to tear down a datastore (`default` ) which is not currently registered with this adapter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45405749/

相关文章:

javascript - Uncaught ReferenceError : Invalid left-hand side in assignment

asp.net - 在我的 UpdatePanel 完成加载其 DOM 元素后,如何从我的代码隐藏执行 JavaScript?

database - 将 Doctrine 2 用于大型数据模型

node.js - 确定代码是否在 sails.js 中执行

javascript - 在 SailsJS 中验证请求参数

javascript - Sails Js 填充条件

javascript - 普通JS : delay click event to add animation

javascript - 使用 HTML5 和 javascript 在播放器全屏而不是背景全屏中自动播放视频

c# - 如何在 UML Java 或 C# 甚至 DB 中建模,客户可以是自然人或公司,并且公司拥有员工和承包商

ruby-on-rails-3 - 在 Rails 模型中格式化日期