Answer the question
In order to leave comments, you need to log in
How to make mongodb javascript unload?
Good afternoon! it was necessary to unload the database from monga so that the separator was a semicolon, I found a working script in javascript (I don’t understand it myself). Now I need to unload a couple more collections, but I don’t know how to change the script so that everything works. please help if it's not difficult. =)
conn = new Mongo();
db = conn.getDB("artixcs");
var cur = db.shop.find();
var obj;
while(cur.hasNext()){
obj = cur.next();
print("\""+obj.displayCode+"\";\""+obj.address+"\"");
}
Answer the question
In order to leave comments, you need to log in
conn = new Mongo();// создаем объект БД
db = conn.getDB("artixcs"); // получаем БД
var cur = db.shop.find(); // находим коллекцию shop и ее в объект cur
var obj; // переменная хранения документа коллекции cur
while(cur.hasNext()){ // итератор по коллекции , т.е. перебирает объекты и спрашивает " а не конец ли коллекции? и если не конец работает код ниже.
obj = cur.next(); // берем документ коллекции и его в переменную
print("\""+obj.displayCode+"\";\""+obj.address+"\""); //тут смотрим поля документа и печатаем
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question