– SQL:
SELECT * FROM UserInfo WHERE userName LIKE "%A%"
– MongoDB:
db.UserInfo.find({userName: /A/})
but haxe current not support
var obj={ "site" : /A/};
any suggestion? thanks.
package;
import mongodb.MongoClient;
import Mongodb;
using tink.CoreApi;
@await
class Main {
public static function main() {
testMongodb();
}
@async
public static function testMongodb() {
var url = "mongodb://127.0.0.1:27017";
var connect:MongoClient = @await Mongodb.connect(url, {useUnifiedTopology: true}).ofJsPromise();
var test = connect.db("testdb").collection('test1');
var effect = @await test.insertOne({"site": "runoob.com" + Random.int(1, 1000000)}).ofJsPromise();
@await test.insertOne({"site": "runoob.com"}).ofJsPromise();
@await test.update({"site": "runoob.com"}, {$set:{"site":"example.com"}}).ofJsPromise();
@await test.deleteMany({"site": /runoob/}).ofJsPromise(); // here is not support.
var arr = @await test.find().toArray().ofJsPromise();
trace(arr);
}
}
dts2hx mongodb