Asynchronous behaviour with N1QL

Hey guys,
Edit: Im using the node sdk
following code:

// with it you basically you add functions (cbLoader.add()) to an array . 
// you can then later execute all functions in the correct order
var cbLoader = new callbackLoader(); 

cbLoader.add(function(cb) { flush(cb); }); //flushing the bucket
for(var i = 0; i < 15; i++){

    // adding test-data
    (function(i){
        cbLoader.add(function(cb) {
            insert("foo:" + i, {"bar" : i}, cb);
        });
    })(i);

    // loading test-data right after each document has been written to couchbase
    (function(i){
        cbLoader.add(function(cb) {
            query("select bar from test where bar = " + i, function(result){
                console.log(result);
                cb();
            });
            // read("foo:" + i, function(result){ // <-- this works
            //     console.log(result);
            //     cb();
            // });
        });
    })(i);
}
// Load all callback-functions in right order
cbLoader.loadAll();

Well, unfortunalety I get very inconsistent result like this one:


[ { bar: 1 } ]
[ { bar: 2 } ]
[ { bar: 3 } ]
[ { bar: 4 } ]

[ { bar: 6 } ]
[ { bar: 7 } ]
[ { bar: 8 } ]
[ { bar: 9 } ]
[ { bar: 10 } ]
[ { bar: 11 } ]
[ { bar: 12 } ]

[ { bar: 14 } ]

I noticed that when i gradually increase the value of i that the new insertions could not be read by the query, but the old ones can be read. That leads to my assumption that the N1QL-query is asynchronous, most of the times the query is even faster than the insert/upsert operation, even when the the insert/upsert-function was called before the query-function. Is this intended? I find it very unsatisfying, since i cannot trust any N1QL-query immediatly called after an data-changing operation.

See scan_consistency settings of REQUEST_PLUS. You can find this in the docs.