-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrepl.ts
More file actions
56 lines (48 loc) · 1.17 KB
/
Copy pathrepl.ts
File metadata and controls
56 lines (48 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { MongoClient } from "mongodb";
import config from "./config.ts";
const client = new MongoClient(config.mongo.url);
const db = client.db("tangledbot");
const players = db.collection("players");
const stats = db.collection("playerStats");
const pipeline = [];
const embedded_pl = [];
// embedded_pl.push({
// $set: {
// joinablePlayerKey: {
// $replaceAll: { input: "$playerKey", find: "nfl", replacement: "449" },
// },
// },
// });
//
// pipeline.push({
// $match: {
// playerKey: "nfl.p.30977",
// },
// });
//
// pipeline.push({
// $lookup: {
// from: "playerStats",
// let: {
// pkey: "joinablePlayerKey",
// },
// pipeline: embedded_pl,
// as: "stats",
// },
// });
//
// // const aggregationResult = await players.aggregate(pipeline);
//
// const aggregationResult = await stats.find({
// playerKey: '449.p.30977'
// }, { sort: ["week", 1] });
const aggregationResult = players.aggregate([
{ $match: { positionAbbr: 'WR' } },
{ $match: { $text: { $search: "brown" } } }
])
for await (const document of aggregationResult) {
console.log(document);
}
console.log("done");
await client.close();
process.exit(0);