nlloyd / horn-of-mongo Goto Github PK
View Code? Open in Web Editor NEWMongoDB Shell built on the Rhino JavaScript Engine for Java.
MongoDB Shell built on the Rhino JavaScript Engine for Java.
db.test.insert({"a":new BinData(0,"iVBORw0K")})
db.test.find()
{ "_id" : ObjectId("51af9949a7d28cd7e29ec528"), "a" : BinData(0,"aVZCT1J3MEs=") }
Result: The binary data became BinData(0,"aVZCT1J3MEs=")
Likely issue with BSONizer.
Cannot create basic types without the "new" keyword, official shell permits this.
/* For function Timestamp() */;
var s=Timestamp()
s
[object]
print(s)
TypeError: Cannot find default value for object.
/* For function ObjectId() /;
var d = ObjectId()
d
[object]
print(d)
TypeError: Cannot find default value for object.
/ For function NumberLong() */;
var i=NumberLong(1)
i
[object]
print(i)
NumberLong(1)
http://docs.mongodb.org/master/release-notes/2.6
Time to upgrade horn-of-mongo!
Details received by email copy-pasted below:
If you execute/evaluate the string " new Mongo('127.0.0.1:27017')" in our shell, you get ...
new Mongo('127.0.0.1:27017')
connection to null
Looks like mongo.js has the method ...
Mongo.prototype.toString = function(){
return "connection to " + this.host;
}
But the Mongo class does not have a "host" member. Should it have one?
Also, if I put a breakpoint in the Mongo() constructor, then evaluate the string above, it will call the constructor twice, once with the innerMongo object and the other with the string provided. Is that a problem?
When the innerMongo object is provided, should the if/else block for this also set the "hosts" member? Like this ...
else if (host instanceof com.mongodb.Mongo) {
this.innerMongo = (com.mongodb.Mongo) host;
this.hosts = innerMongo.getServerAddressList();
} else if (host instanceof List<?>)
How thread-safe is MongoScope? Need a test to run multiple threads with long running processes against the same MongoScope instance.
clear
ReferenceError: "clear" is not defined.
exit
ReferenceError: "exit" is not defined.
quit
function quit() {
[native code, arity=1]
}
Basically: do what PrintHandler interface does for print(...), but now add 3 others.
Hi, I'm trying to connect to a local mongo instance using the Disconnected MongoScope method and the call to MongoRuntime.call() is throwing a syntax error exception when I use a password with special characters, e.g., "?" and "~". If I start mongod without using the "--auth" option and remove user/pass from the connection string in the call to new MongoScriptAction(), everything works as expected. The error appears to be in the call to the cx.evaluateString method inside MongoScriptAction.doRun method.
Any help is appreciated, thanks.
ScriptableMongoObject overrides the default "prototype" behavior by using a static registry to store the prototype for each ScriptableMongoObject. Effectively all instances of the same object type share the same prototype. However, when various javascript objects are compiled, they contain a reference to the MonoScope object. Thus the objects in each prototype are tied to a certain MonoScope. Because of this, this implementation does not properly support the use of multiple MongoScope.
In order to be able to support multiple "shells" within 1 JVM, there needs to be a separate prototype registry per MongoScope or per "context". However, one complication is that the first call to ScriptableMongoObject.getPrototype(), right after an object instance is created, the "mongoScope" variable is null.
The following features are missing:
(in the official mongo shell)
help
... print out of help data
show dbs
... show databases in current instance/cluster
show collections
... show collections in current db
For better integration with projects that use a logging framework there should be a ready-to-go PrintHandler implementation using slf4j for maximum compatibility across logging frameworks in the Java space.
Functionality available in the mongo shell but TODO in horn-of-mongo:
help admin
ls([path]) list files
pwd() returns current directory
listFiles([path]) returns file list
hostname() returns name of this host
cat(fname) returns contents of text file as a string
removeFile(f) delete a file or directory
load(jsfilename) load and execute a .js file
run(program[, args...]) spawn a program and wait for its completion
runProgram(program[, args...]) same as run(), above
sleep(m) sleep m milliseconds
getMemInfo() diagnosticgetHostName()
ReferenceError: "getHostName" is not defined.
getMemInfo()
ReferenceError: "getMemInfo" is not defined.
hostname()
ReferenceError: "hostname" is not defined.
listFiles()
ReferenceError: "listFiles" is not defined.
db.runCommand('Customers');
{
"serverUsed" : "/10.168.11.47:27017",
"ok" : 0,
"errmsg" : "no such cmd: Customers",
"bad cmd" : {
"Customers" : 1
}
}
db.runCommand();
Wrapped java.util.NoSuchElementException (mongodb/query.js#77)
db.getCollection("$cmd").findOne()
Wrapped java.util.NoSuchElementException (mongodb/query.js#77)
The db.runCommand() doesn't return a result the way the Mongo CLI does. It calls Mongo.find() at line 163 which throws an exception because DB.command():74 calls :
String comString = command.keySet().iterator().next();
Which throws NoSuchElementException.
Hi Nick,
I've produced a fork that works with rhino 1.7.7 and mongo-java-driver 3.1.0.
Would you be interested in considering these changes for a new release of h-o-m?
Thanks,
Gerald.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.