uncaught exception: Error: couldn't add user: Could not find role: root@admin : 报错的解决方法
在 MongoDB 创建用户账号遇到了 这个问题1234uncaught exception: Error: couldn't add user: Could not find role: root@admin :_getErrorWithCode@src/mongo/shell/utils.js:25:13DB.prototype.createUser@src/mongo/shell/db.js:1367:11@(shell):1:1 这个意思是说 roles 里没有 root 这个关键字就是用户的 roles 不能用 root 这个关键字报错原因是因为除了 admin 其他的角色(roles)不能用 root,其他的用户的角色(roles)是有固定的写法 比如(readWrite)解决方法改变 roles 的值 角色有:Read:允许用户读取指定数据库readWrite:允许用户读写指定数据库dbAdmin:允许用户在指定数据库中执行管理函数,如索引创建、删除,查看统计或访问 system.profileuserAdmin:允许用户向 system.users...
解决.ignore不生效问题
问题概述其实这个问题很简单,主要是因为我们的项目不是在构建之前就加入了 ignore 规则,而是在某些文件已经纳入版本控制之后添加的规则,所以规则不生效 我们的解决方案也很容易理解,在本地清理下 git 的缓存,重新提交规则文件就能解决 解决方案git 终端,依次键入如下指令 123456$ 清理缓存git rm -r --cached .$ 跟踪所有文件git add .$ 重新提交git commit -m 'update .gitignore' 原文: Git .ignore 文件规则不生效_攻城狮杰森的博客-CSDN 博客_ignore 不生效
关于Koa洋葱圈模型的第一次体验
使用 log4js 打日志的时候,获取不到上下文的 status 状态码,解决方案:利用 Koa 洋葱圈模型和 await 的用法,在路由前使用 Logger 中间件,app.use(AccessOrigin).use(Logger).use(router.routes()); 中间件里使用1234567const Logger = async (ctx: Context, next: Next) => { await next(); const logContent = `${ctx.status} | ${ctx.headers.origin || "undefined"} | ${ ctx.method } | ${ctx.path}`; logger.info(logContent);}; 实现请求结束以后再执行日志内容拼接