Closed mlaspina closed 5 years ago
Ok, thanks @mlaspina. I'll take a look.
Can you provide the error or more information? I'm trying it with mongod 3.0.6 and it looks like things are in order:
> db.cats.find()
{ "_id" : ObjectId("550ddfd308bb316c19c781f0"), "name" : "Zildjian", "__v" : 0 }
{ "_id" : ObjectId("550de03d6013538819cd8ab0"), "name" : "Zildjian", "__v" : 0 }
> var c = db.cats.aggregate()
> while (c.hasNext()) { printjson(c.next()) }
{
"_id" : ObjectId("550ddfd308bb316c19c781f0"),
"name" : "Zildjian",
"__v" : 0
}
{
"_id" : ObjectId("550de03d6013538819cd8ab0"),
"name" : "Zildjian",
"__v" : 0
}
>
Tyler, Attached are the JSON file you can import into a DB. I called the collection ‘main’. After importing the document, you can run the file audit_js.txt and you will get the following error with Mongo Hacker installed:
Mikes-MacBook-Pro(mongod-3.0.5) xactware> load ("audit_js.txt")
2015-09-25T09:13:18.912-0700 E QUERY TypeError: Object [object Object] has no method 'hasNext'
at audit_js.txt:29:10
at (shell):1:1 at audit_js.txt:29
2015-09-25T09:13:18.913-0700 E QUERY Error: error loading js file: audit_js.txt
at (shell):1:1
If I uninstall mongo hacker, it works fine.
The JSON and the script files are attached.
I ran this in 3.0.5 if you think that may make a difference.
On Sep 25, 2015, at 9:09 AM, Tyler Brock notifications@github.com wrote:
Can you provide the error or more information? I'm trying it with mongod 3.0.6 and it looks like things are in order:
db.cats.find() { "_id" : ObjectId("550ddfd308bb316c19c781f0"), "name" : "Zildjian", "v" : 0 } { "_id" : ObjectId("550de03d6013538819cd8ab0"), "name" : "Zildjian", "__v" : 0 } var c = db.cats.aggregate() while (c.hasNext()) { printjson(c.next()) } { "_id" : ObjectId("550ddfd308bb316c19c781f0"), "name" : "Zildjian", "v" : 0 } { "_id" : ObjectId("550de03d6013538819cd8ab0"), "name" : "Zildjian", "__v" : 0 }
— Reply to this email directly or view it on GitHub https://github.com/TylerBrock/mongo-hacker/issues/141#issuecomment-143263600.
db.audit.createIndex({"time" : -1})
var c = db.main.aggregate( [ { $project : { "projGUID" : "$PROJECT_INFO.projGUID", "AUDIT_ENTRIES" : "$AUDIT_ENTRIES", "_id" : 0} }, { $unwind : "$AUDIT_ENTRIES" } , { $project : {"projGUID" : "$projGUID", "afterAmtSpecified" : "$AUDIT_ENTRIES.afterAmtSpecified", "userID" : "$AUDIT_ENTRIES.userID", "userName" : "$AUDIT_ENTRIES.userName", "type" : "$AUDIT_ENTRIES.type", "note" : "$AUDIT_ENTRIES.note", "to" : "$AUDIT_ENTRIES.to", "from" : "$AUDIT_ENTRIES.from", "sessNumSpecified" : "$AUDIT_ENTRIES.sessNumSpecified", "extra1Specified" : "$AUDIT_ENTRIES.extra1Specified", "extra3" : "$AUDIT_ENTRIES.extra3", "time" : "$AUDIT_ENTRIES.time", "xid" : "$AUDIT_ENTRIES.xid", "extra2" : "$AUDIT_ENTRIES.extra2" } } ] );
while (c.hasNext()) { db.audit.insert(c.next()); };
Files are at https://gist.github.com/mlaspina/d5e71ea0b8451dd005fd as well.
Oh, thanks for following up Mike but please don't post any private information here. Everyone can see the data in the gist. I hope it isn't sensitive. Perhaps e-mail it to me personally (and also be sure you want to do that before doing so)
Closing old issues to clean up the backlog. I suspect this has been resolved, but if you see a similar problem please open a fresh bug report with details of your environment (versions of Mongo Hacker, mongo
shell, and MongoDB server).
I can't get an agg framework query to return a cursor with mongo-hacker enabled. The following returns an error with mongo-hacker installed,but works fine after uninstalling:
var c = db.main.aggregate( [ { $project : { "projGUID" : "$PROJECT_INFO.projGUID", "AUDIT_ENTRIES" : "$AUDIT_ENTRIES", "_id" : 0} }, { $unwind : "$AUDIT_ENTRIES" } , { $project : {"projGUID" : "$projGUID", "userID" : "$AUDIT_ENTRIES.userID", : } } ] );
while (c.hasNext()) { //Causes an error };