Files
lila/ui/botDev/bin/export-bots.js

12 lines
256 B
JavaScript

const docs = [];
db.jsbot
.aggregate([
{ $sort: { version: -1 } },
{ $group: { _id: '$uid', doc: { $first: '$$ROOT' } } },
{ $replaceRoot: { newRoot: '$doc' } },
])
.forEach(doc => docs.push(doc));
print(JSON.stringify(docs, null, 2));