import { MongoDB } from '../build/esm/index.js'; const mongo = new MongoDB({ createLogger: () => { return { debug: console.log, info: console.log, status: console.log, warn: console.log, error: console.error }; } }, { credentials: { URI: 'mongodb://127.0.0.1:27017', database: 'framework-proto' }, load: true }); await mongo.init(); const user = await mongo.findOne('users', { name: 'navy' }); console.log(user, user._id.toString()); // const query = { // serverType: 'Matchmaking' // }; // const [ result ] = await mongo.collection('reservedServers').aggregate([ // { $match: query }, // { $group: { _id: null, allPlayers: { $push: '$players' } } }, // { $project: { _id: 0, allPlayers: { $reduce: { input: '$allPlayers', initialValue: [], in: { $concatArrays: [ '$$value', '$$this' ] } } } } }, // { $project: { allPlayers: { $sortArray: { input: '$allPlayers', sortBy: { playerElo: -1 } } } } } // ]).toArray(); // console.log(result); const result = await mongo.find('locations', {}); const ips = result.map(loc => loc.ip); const ranges = new Set(ips.map(ip => ip.split('.').slice(0, 3).join('.'))); console.log(ranges); await mongo.close();