LukeDev2K
LukeDev2K
  • 发布:2022-01-14 11:29
  • 更新:2022-01-14 15:52
  • 阅读:461

云开发使用RegExp 在腾讯云报错

分类:uniCloud
const res = await db.collection('doc')  
				.aggregate()  
				.match({  
					name: new db.RegExp({  
						regex: keyword,  
						options: 'i'  
					})  
				})  
				.sample({  
					size: 1  
				})  
				.end()

想通过正则模糊搜索文档,这段代码在阿里云是通的,但是换成腾讯云就报错了,要怎么写呢?

错误:
TypeError: regexp must be a string

2022-01-14 11:29 负责人:无 分享
已邀请:
DCloud_uniCloud_WYQ

DCloud_uniCloud_WYQ

你打印一下你传的keyword是啥,另外这段代码是云函数里面运行的还是客户端运行的

LukeDev2K

LukeDev2K (作者) - 小程序,app

解决了,是字段写错,打扰了
regex=>regexp

该问题目前已经被锁定, 无法添加新回复