我正在使用 MongoDB(3.4 版)作为其数据库在 Windows 中运行节点 js 应用程序。在运行 node js 服务器时突然出现此错误之前,它运行良好:
MongoError: no primary found in replicaset
at C:\Users\common\server\nodeapp\node_modules\mongodb-core\lib\topologies\replset.js:524:28
Run Code Online (Sandbox Code Playgroud)
在 Windows 命令提示符中,我用命令 mongod 启动了 mongo db,最后显示了以下消息:
2017-01-12T21:02:30.286+0530 I NETWORK [thread1] connection accepted from 127.0.0.1:53591 #3 (3 connections now open)
2017-01-12T21:02:30.294+0530 I NETWORK [thread1] connection accepted from 127.0.0.1:53592 #4 (4 connections now open)
2017-01-12T21:02:30.320+0530 I - [conn4] end connection 127.0.0.1:53592 (4 connections now open)
2017-01-12T21:02:30.321+0530 I - [conn2] end connection 127.0.0.1:53590 (4 connections now open)
2017-01-12T21:02:30.321+0530 I - [conn3] end connection 127.0.0.1:53591 …Run Code Online (Sandbox Code Playgroud) 我正在寻求从模块MoreUtils.pm解释Perl的uniq和fidrstidx函数的语法.
在寻找之后,我已经知道了从具有重复元素的数组中获取uniq数组元素并通过以下方式从数组中查找第一个索引的其他方法:
## remove duplicate elements ##
my @arr = qw (2 4 2 8 3 4 6);
my @uniq = ();
my %hash = ();
@uniq = grep {!$hash{$_}++ } @arr;
### first index ###
@arr = qw (Java ooperl Ruby cgiperl Python);
my ($index) = grep {$arr[$_] =~ /perl/} 0..$#arr;
Run Code Online (Sandbox Code Playgroud)
任何人都可以解释我下面这个sub uniq函数的第二行,包括来自MoreUtils.pm的map和ternary运算符:
map {$h{$_}++ == 0 ? $_ : () } @;
Run Code Online (Sandbox Code Playgroud)
并且
&@传递给firstidx函数和函数体中的下一行:
local *_ = \$_[$i];
Run Code Online (Sandbox Code Playgroud)
据我所知,sub例程ref被传递给firstidx.但是更加详细的解释将非常感激.
谢谢.