Aggregation stage $out allows us to output the result of the aggregation pipeline into a new collection:
db.sightings.aggregate([
{ $match: { species_common: "Eastern Bluebird" } },
{ $out: "sightings_2022" },
]);
db.sightings_2022.find({})[
({
_id: ObjectId("62cf2f0acfe5bbb25ee815fb"),
species_common: "Eastern Bluebird",
species_scientific: "Sialia sialis",
date: ISODate("2022-01-17T18:24:00.000Z"),
location: { type: "Point", coordinates: [41, -74] },
},
{
_id: ObjectId("62cf8ebfbb9cdbee29caab04"),
species_common: "Eastern Bluebird",
species_scientific: "Sialia sialis",
date: ISODate("2022-01-18T21:09:00.000Z"),
location: { type: "Point", coordinates: [40, -74] },
},
{
_id: ObjectId("62cf8eb2bb9cdbee29caab03"),
species_common: "Eastern Bluebird",
species_scientific: "Sialia sialis",
date: ISODate("2022-01-18T23:55:40.000Z"),
location: { type: "Point", coordinates: [40, -74] },
},
{
_id: ObjectId("62cf8e9fbb9cdbee29caab02"),
species_common: "Eastern Bluebird",
species_scientific: "Sialia sialis",
date: ISODate("2022-01-18T18:22:20.000Z"),
location: { type: "Point", coordinates: [40, -74] },
},
{
_id: ObjectId("62cf32bdcfe5bbb25ee815fc"),
species_common: "Eastern Bluebird",
species_scientific: "Sialia sialis",
date: ISODate("2022-01-18T18:24:00.000Z"),
location: { type: "Point", coordinates: [40, -73] },
})
];