Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
请我需要这个查询'从productos'中选择名称'prod%'的产品'但是使用节点和mongo db,现在我有这个:
query["$or"].push({'product': new RegExp(cadsrch, 'i')});
这会做到这一点->'%prod%',但我需要'prod%'。
大概是这样的:
query["$or"].push({'product': new RegExp('^'+cadsrch, 'i')});
前缀^说:从字符串的开头。
^