Because MongoDB supports executing JavaScript file queries, newLISP can get query results this way.
Here is my newLISP module:
(Context ' Mongo_js_tool) (Define (query Db-name js-file) (Set ' cmd (format "MONGO localhost/%s%s" Db-name js-file)) (SET ' R (exec cmd)) (Set ' R (String_list:remove r "^mongodb.+" 1)) (Set ' R (String_list:remove r "^connecting.+" 1)) (SET ' RL ' ()) (Set ' line "") (Dolist (e R) (Set ' line (Append line (replace "\ T" E "") )) (if (= "}" e) (Begin (Push line RL-1) (Set ' line " )))) RL )
Here is the invoke command:
(Load "MONGO.LSP") (SET ' RL (mongo_js_tool:query "KFC" "Strategy.js")) (println RL)
The execution results are:
./SCHEDULE.LSP ("{\" _id\ ": ObjectId (\" 53bbf667b78d338d48d0f86f\ "), \" send_time\ ": \" 21:47\ ", \" text\ ": \" afdfd\ "}" "{\" _id\ ": ObjectId (\" 53cb4c625f94f3ac8af92b46\ "), \" send_time\ ": \" 06:29\ ", \" text\ ": \" 66gg\ "}")
newLISP querying MongoDB Records via JavaScript