MongoDB怎样获取带数字等非正常名称集合

在mongodb数据库操作中,如果使用常规的方法获取带数字等非正常名称集合,会获取失败,并会返回identifier starts immediately after numeric literal 错误。

> db.userInfo-1.drop()

2018-06-24T20:26:34.585+0800 E QUERY    [thread1] SyntaxError: identifier starts immediately after numeric literal @(shell):1:12



可以使用getCollection()方法获取非正常名称的集合以进行下一步操作。

> db.getCollection("userInfo-1").drop()
true

猜你喜欢

转载自blog.csdn.net/yuhui01/article/details/80794238