I need your help with couchbase + n1ql concept insert/update/select in nodejs
I’m working on user application, which is using classic concept
Insert a new doc or update existing doc and then after this action quick read back this new saved doc.
This is my code example for better explanation:
- step
function insertData(){
db.insert(doc_id, doc, function(err, meta){
if(err){
console.log(err);
} else {
readData();
}
});
} - step
function readData(){
var _sQuery = “SELECT * FROM bucket”;
db.query(db_n1ql.fromString(_sQuery), function(err, resultset){
// resultset is empty
});
} - step
i call again this function readData and now is this doc in resultset
…
so a first time i will try of call function readData right after data are inserted into Couchbase is resultset empty.
When i call this function readData a second time, then resultset return correctly this new inserted doc.
Why is this new inserted doc not on first time properly selected ?
It was very quickly selected and index was not yet updated ?
I think, that for this is in ViewQuery object parameter Update (stale)
but in N1qlQuery ?