Javascript non-blocking
Javascript non-blocking
本文关键字:non-blocking Javascript 更新时间:2023-09-26
我的要求是先打开数据库,然后执行第二种方法。我试过我没有在JS中做过这样的事情,所以任何建议/指导都非常感谢。
我的代码可以在这里找到。如何使它异步?我可以选择设置超时,但我找不到好的做法......
任何示例都将非常有帮助。
这段代码来自这个 https://github.com/mongodb/node-mongodb-native 自述文件
var MongoClient = require('mongodb').MongoClient
, format = require('util').format;
MongoClient.connect('mongodb://127.0.0.1:27017/test', function(err, db) {
if(err) throw err;
var collection = db.collection('test_insert');
collection.insert({a:2}, function(err, docs) {
collection.count(function(err, count) {
console.log(format("count = %s", count));
});
// Locate all the entries using find
collection.find().toArray(function(err, results) {
console.dir(results);
// Let's close the db
db.close();
});
});
})
相关文章:
- 使用ja将对象添加到HTML画布中
- 在requirejs中调用non amd的函数
- 如何从document.getElementsByClassName('myTxtBox');中获取ja
- Validate.JS - DISallow Non-ASCII Unicode Characters
- JavaScript blocking CSS
- 如何仅按名称计算元素长度,而不是使用 javascript 显示 non
- Javascript non-blocking
- Javascript blocking css?
- 在 Jsctypes 中将 char * 从 javascript 传递到 c,并将 char * 从 c 传递到 ja
- 是否可以避免使用getter和setter的模式,并且仍然使用闭包ADVANCED_OPTIMIZATIONS最小化Ja
- None Blocking setTimeout(fn, 0)
- Non jQuery lightbox
- Canvas Blocking Page?
- 如何重置“;readonly=true”;从php创建的表单中的输入字段为“”;readonly=false”;使用ja
- JavaScript-如何异步加载外部脚本NON
- Firefox blocking Facebook Js
- javascript escape vs urlencode of non-ascii strings
- 无法在chrome本地存储中使用jquery,如何使用.remove() jquery方法的css:有伪选择器只使用ja
- non-'terminating'的正确或标准写法代码
- Require.ensure() non-blocking