In CF-2021 native mongodb support was added. Has a...
# cfml-general
s
In CF-2021 native mongodb support was added. Has anyone tried the mongo features? I'm trying the code mostly from the limited samples of the doc:
Copy code
var db = getmongoservice(application.settings.mongoDS).db("newdb"); // create a db 
 db.createCollection("colFindDemo"); // create a collection 
 db.colFindDemo.insertMany([ 
   
   { "_id" : 1, "name" : "Ian Gillan", "instrument" : "Vocals","born": 1945 }, 
   { "_id" : 2, "name" : "Ian Paice", "instrument" : "Drums", "born" : 1948 }, 
   { "_id" : 3, "name" : "Roger Glover", "instrument" : "Bass", "born" : 1945 }, 
   { "_id" : 4, "name" : "Steve Morse", "instrument" : "Guitar", "born" : 1954 }, 
   { "_id" : 5, "name" : "Don Airey", "instrument" : "Keyboards", "born" : 1948 }, 
   { "_id" : 6, "name" : "Jeff Martin", "instrument" : "Vocals", "born" : 1969 }, 
   { "_id" : 7, "name" : "Jeff Burrows", "instrument" : "Drums", "born" : 1968 }, 
   { "_id" : 8, "name" : "Stuart Chatwood", "instrument" : "Bass", "born" : 1969 } 
   
 ]);
 // return all documents 
 var col = db.colFindDemo.find();
writeDump(var=col, label="col");
abort;
The createCollection call seems to put itself into an infinite loop condition and eventually crashes with an out of stack message. Any ideas? Or any better examples somewhere?
m
Steve, we are working on a project which will add reusable code samples in a variety of patterns for our developers to leverage. Mongo DB samples are on the list, and should hopefully be put up in our community portal in a month or so.
s
That would be awesome.
@Mark Takata (Adobe), any chance I could get a prerelease working sample - including the output of the found results? The current sample only goes to find(), it does not show how to use the found results.
(maybe a working trycf.com sandbox) 😁
m
@saghosh could we get a bit more details on our MongoDB documentation to show how to leverage the output of the find() at the end? We won't have the code snippets for a while from the project I mentioned