Skip to content

devkev/mongoquine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mongoquine

A MongoDB Aggregation that outputs itself.

asciicast

> var cmd = JSON.parse(cat("mongoquine.json"))
> bsonWoCompare(cmd, db.runCommand(cmd).cursor.firstBatch[0])
0

mongoquine.json contains the aggregation itself, in command form (ie. parse as JSON and then use db.runCommand()). There should be a single document in the quine collection (can have any contents). The aggregation will return a single document, which can be accessed via the cursor.firstBatch[0] field of the command return. This returned document will be identical to the command document that was sent via runCommand().

quine-tester.js contains a mongo shell test runner to see if a given file is such a quine. It uses (ie. drops) the quine db. Run it as:

mongo --host ... --port ... --eval 'filename = "mongoquine.json"' quine-tester.js

Requires MongoDB 3.4.4 or higher. My understanding is that due to the way $literal works, it's not possible to use this approach without $arrayToObject (which was introduced in version 3.6 and backported to 3.4.4). (Other approaches might be possible; I haven't tried.)

About

A MongoDB Aggregation that outputs itself.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published