0

我正在尝试在 cassandra 中插入地图类型:

const query = 'INSERT INTO stats.tickets (office, line, generation, inserted_at, meta, number, prefix) VALUES (:office, :line, :generation, :inserted_at, :meta, :number, :prefix)';

const parametersExample = {
    office: "office",
    line: "line",
    generation: 10,
    inserted_at: Date.now(),
    meta: {"tag1": "ujkukkik", "tag2": "asdascee"},
    number: 1,
    prefix: "prefix_"
};

const result = async () => {
    return await client.execute(query, parametersExample, { prepare: true });
};

result().then( res => {
    res.rows.map( row => console.log(row.content) );
    process.exit();
}).catch( err => console.error(err));

代码插入行但显示以下消息:

TypeError: Cannot read property 'map' of undefined
at lib/handleData.js:23:14
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7)

是什么原因?

4

1 回答 1

2

这是正常行为 - 根据CQL 文档

除非使用 IF NOT EXISTS,否则 INSERT 不会返回任何结果。

所以驱动程序接收undefined...通常.map将用于选择。

于 2018-08-24T18:37:53.693 回答