Closed CrazyFlasher closed 3 years ago
package ; import js.Error; import js.npm.mongodb.MongoClient; import js.npm.mongodb.MongoCollection; import js.npm.mongodb.MongoDatabase; import js.Promise; @await class Main2 { static function main() { MongoClient.connect("mongodb://127.0.0.1:27017", null, (e:Error, db:MongoDatabase) -> { trace("Connected!"); var c:MongoCollection = db.db("admin").collection("Employee"); find(c); }); } @async private static function find(c:MongoCollection):Void { var r = @await cast (c.findOne({EmployeeName: "Zopa"}), Promise<Dynamic>); trace(r); } }
This library only works with tink.core.Promise but not js.lib.Promise You can use tink.core.Promise.ofJsPromise(jsPromise) to perform the conversion.
tink.core.Promise
js.lib.Promise
tink.core.Promise.ofJsPromise(jsPromise)