0

我只想应用以下教程的绑定并应用于我的项目: http ://express-cassandra.readthedocs.io/en/latest/usage/

我当前的模型位于名为 UserModel.js 的模型目录中:

module.exports = {
    fields:{
        name    : "text",
        surname : "text",
        age     : "int",
        created : "timestamp"
    },
    key:["name"]
}

index.js 绑定最后一个模型:

var models = require('express-cassandra');

models.setDirectory( __dirname + '/models').bind(
    {
        clientOptions: {
            contactPoints: ['127.0.0.1'],
            protocolOptions: { port: 9042 },
            keyspace: 'pop',
            queryOptions: {consistency: models.consistencies.one}
        },
        ormOptions: {
            defaultReplicationStrategy : {
                class: 'SimpleStrategy',
                replication_factor: 1
            },
            migration: 'safe'
            createKeyspace:true
        }
    },
    function(err) {
        if(err) throw err;


    }
);

    module.exports{
models:models
}

连接正常,但是在成功连接到 casandra db(localhost:9042) 后,它向我显示一条消息:“Keyspace user_schema 不存在” 谁能给我一个解决这个问题的想法?可能没有加载模型,但看起来还可以,但是在加载模型之前它不识别密钥空间,而且它是我数据库的正确密钥空间

4

1 回答 1

0

我更新了 express-cassandra,现在它可以工作了,问题是兼容性

于 2018-02-14T14:04:38.967 回答