Very new to pymongo. I have a database 'db' with a collection 'data' that I populate from a plain text file with one program. Another program runs every hour or so and checks for new entries in the log file. It looks at the last entry in the log file and converts it into a mongo document 'newdata', then compares the datetime of that document to the datetime of the latest entry in 'data'. If the datetime of 'newdata' is greater, it adds 'newdata' to another collection 'xdata'.
This loop runs until the dates equal eachother, at which point I want it to take the documents from 'xdata' and add them to 'data' in the reverse of their order in 'xdata'. I'm trying to do this with:
db.xdata.find().sort([["_id", -1]]).forEach(function(doc) {
db.data.insert(doc)
})
and then I clear 'xdata' with db.xdata.remove()
.
When I try to run this, I get
SyntaxError: invalid syntax
With an arrow point to the first '{'.
Any help is greatly appreciated.