可能重复:
Mongo接口
我一直在浏览mongoDB可用的GUI工具.我看到了mongoHub(令人遗憾的是它仅适用于MAC OSX),rockMongo和其他一些基于php的工具.有没有其他工具可用的桌面应用程序,如MYSQL GUI工具?
我想知道javascript中以下条件结构的实现的性能.
方法1:
if(id==="camelCase"){
window.location.href = "http://www.thecamelcase.com";
}else if (id==="jsFiddle"){
window.location.href = "http://jsfiddle.net/";
}else if (id==="cricInfo"){
window.location.href = "http://cricinfo.com/";
}else if (id==="apple"){
window.location.href = "http://apple.com/";
}else if (id==="yahoo"){
window.location.href = "http://yahoo.com/";
}
Run Code Online (Sandbox Code Playgroud)
方法2:
switch (id) {
case 'camelCase':
window.location.href = "http://www.thecamelcase.com";
break;
case 'jsFiddle':
window.location.href = "http://www.jsfiddle.net";
break;
case 'cricInfo':
window.location.href = "http://www.cricinfo.com";
break;
case 'apple':
window.location.href = "http://www.apple.com";
break;
case 'yahoo':
window.location.href = "http://www.yahoo.com";
break;
}
Run Code Online (Sandbox Code Playgroud)
方法3
var hrefMap = {
camelCase : "http://www.thecamelcase.com",
jsFiddle: "http://www.jsfiddle.net",
cricInfo: "http://www.cricinfo.com",
apple: "http://www.apple.com", …Run Code Online (Sandbox Code Playgroud) 有没有办法可以通过Java驱动程序修改MongoDb中某个键的值.我尝试了以下内容:
someCollection.update(DBObject query, DBObject update);
someCollection.findAndModify(DBObject query, DBObject update);
Run Code Online (Sandbox Code Playgroud)
但这两个函数都完全用更新的文档替换查询的文档.在mongo shell中使用$ set的情况下,只更新特定键的一个值的方法是什么.(除了创建一个全新的文档,其中复制了所有字段并更新了其中一个字段).
我想知道是否有一种方法可以直接通过Java执行类似查询的mongo,即我们将mongoDB查询作为字符串提供给Java驱动程序中的函数,用于mongoDB作为String对象并返回DBCursor对象.就像是:
import com.mongodb.*;
import java.net.UnknownHostException;
public class ExecuteQuery {
public static void main(String args[]){
try{
Mongo m = new Mongo();
DB db = m.getDB("test");
DBCollection coll = db.getCollection("first");
DBObject doc = new BasicDBObject();
DBCursor cur =coll.executeQuery("db.first.find({"username":"joe"})");
}
catch(UnknownHostException e){
System.out.println(e);
}
catch (MongoException.DuplicateKey e) {
System.out.println("Exception Caught" + e);
}
}
}
Run Code Online (Sandbox Code Playgroud)
注意:executeQuery()不是内置函数.它仅用于演示目的.那么,java api中是否有一个将json字符串转换为BasicDBObject实例的函数?谢谢.
我去了各种网站,但无法理解以下向自定义对象添加方法的方法之间的区别:
方法1:
function circle(radius){
this.radius = radius;
this.area = function(){ return 3.14*this.radius*this.radius;}
}
Run Code Online (Sandbox Code Playgroud)
方法2:
function circle(radius){
this.radius = radius;
}
circle.prototype.area = function(){ return 3.14*this.radius*this.radius; }
Run Code Online (Sandbox Code Playgroud)
是否存在其中一种方法存在的性能或设计问题,另一种方法没有?
我知道如何使用动作侦听器并实现它们,但我想知道是否有人能告诉我他们如何听取事件?有某种投票机制吗?
我已经搜索了这段时间了很长时间但是无法找到一个方法来使用where子句或条件.例如,如果我有一个集合Cars,我尝试执行以下操作:
Cars.where({
model: 1998,
color: 'Black',
make: 'Honda'
})
Run Code Online (Sandbox Code Playgroud)
那么上面需要做的是寻找一个car它model是1998和color是Black和make是Honda.
但我需要一种方法来获得cars哪三个条件都是真的.
在小胡子,如果我们有一个像这样的数组:
var a = [1,2,3,4];
Run Code Online (Sandbox Code Playgroud)
我们可以创建如下模板:
{{#a}}
{{.}}
{{/a}}
Run Code Online (Sandbox Code Playgroud)
迭代它.现在,如果我们有一些像
var a = [[1,2], [3,4], [5,6]]
Run Code Online (Sandbox Code Playgroud)
我们可以创建一个模板,如:
{{#a}}
key is {{0th element}} and the value is {{1st element}}
{{/a}}
Run Code Online (Sandbox Code Playgroud) 有没有办法获得mongostat实用程序的结果,如no.通过java驱动程序查询/秒,插入/秒等.我发现的一种方法是通过Mongo对象获取serverstatus:
db.command("serverStatus")
Run Code Online (Sandbox Code Playgroud)
然后获取到目前为止执行的总查询,然后操纵它以获得每秒查询.
有没有其他更好的方法来获取此信息?
我使用Eclipse Indigo和subeclipse作为eclipse的svn插件.现在是这种情况.我正在将我的项目与远程存储库同步.存在冲突,我错误地点击其中一个文件的"标记合并"而没有合并它.我尝试重新启动eclipse和其他一些愚蠢的黑客攻击.但没有任何效果.那么有没有办法撤消"标记为合并"的行动?
请解释以下在javascript函数中编写函数的方法:
(function (){
// some code
})()
Run Code Online (Sandbox Code Playgroud)
我理解这样一个事实:由于尾随大括号"()",函数会立即执行,但是括号中的函数是什么意思呢?
我正在尝试一些示例,并遇到一个问题,如果我们想要向原型添加一个函数,它将无法访问构造函数的私有成员.我遇到了这个解决方案.这似乎是一个很好的黑客.
我尝试了其他一些方法,我得到以下内容:
var Restaurant = function()
{
var myPrivateVar;
var private_stuff = function() // Only visible inside Restaurant()
{
return "I can set this here!";
}
Restaurant.prototype.use_restroom = function() // use_restroom is visible to all
{
private_stuff();
}
Restaurant.prototype.buy_food = function() // buy_food is visible to all
{
return private_stuff();
}
}
var restaurant = new Restaurant();
restaurant.buy_food(); // this would work
restaurant.private_stuff(); // this won't
Run Code Online (Sandbox Code Playgroud)
解决方案似乎很奇怪,因为我们在构造函数中添加了原型.(我没有看到太多这个).它至少适用于firefox 5和chrome.它有什么问题吗?
javascript ×6
mongodb ×5
java ×4
arrays ×1
backbone.js ×1
constructor ×1
eclipse ×1
if-statement ×1
iife ×1
json ×1
mongo-java ×1
monitoring ×1
mustache ×1
pull ×1
svn ×1
swing ×1