How to write the same obj value as Mongodb?

– 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.

update: fixed

use Syntax.code

That depends on a library you’re using to access MongoDB.

current we use dts2hx auto convert nodejs mongodb lib to haxe.

using tink.CoreApi;


    class Main {

        public static function main() {





        public static function testMongodb() {

            var url = "mongodb://";

            var connect:MongoClient = @await Mongodb.connect(url, {useUnifiedTopology: true}).ofJsPromise();

            var test = connect.db("testdb").collection('test1');

            var effect = @await test.insertOne({"site": "" +, 1000000)}).ofJsPromise();

            @await test.insertOne({"site": ""}).ofJsPromise();

            @await test.update({"site": ""}, {$set:{"site":""}}).ofJsPromise();


            @await test.deleteMany({ "site": /A/ }).ofJsPromise();//here is not support.

            var arr = @await test.find().toArray().ofJsPromise();




Then you should do it the same way it’s done in JS.
I guess /A/ is a regular expression literal which creates an instance of RegExp. So, in Haxe it may look like new js.lib.RegExp('A')