MongoUtility.Command.CommandExecute.ExecuteJsShell C# (CSharp) Method

ExecuteJsShell() public static method

使用Shell Helper命令
public static ExecuteJsShell ( string jsShell, MongoServer mongoSvr ) : CommandResult
jsShell string
mongoSvr MongoServer
return MongoDB.Driver.CommandResult
        public static CommandResult ExecuteJsShell(string jsShell, MongoServer mongoSvr)
        {
            var shellCmd = new BsonDocument
            {
                { "$eval", new BsonJavaScript(jsShell)},
                { "nolock", true }
            };
            //必须nolock
            var mongoCmd = new CommandDocument();
            mongoCmd.AddRange(shellCmd);
            return ExecuteMongoSvrCommand(mongoCmd, mongoSvr);
        }

Usage Example

Beispiel #1
0
        /// <summary>
        ///     删除服务器
        /// </summary>
        /// <param name="mongoSvr">副本组主服务器</param>
        /// <param name="hostPort">服务器信息</param>
        /// <remarks>这个命令C#无法正确执行</remarks>
        /// <returns></returns>
        public static CommandResult RemoveFromReplsetServer(MongoServer mongoSvr, string hostPort)
        {
            var mCommandResult = new CommandResult(new BsonDocument());

            try
            {
                CommandExecute.ExecuteJsShell("rs.remove('" + hostPort + "');", mongoSvr);
            }
            catch (EndOfStreamException)
            {
            }
            return(mCommandResult);
        }
All Usage Examples Of MongoUtility.Command.CommandExecute::ExecuteJsShell