larryclyons
12/27/2024, 4:32 PMpublic any function getSeasons() output="false" {
var db = getmongoservice("mongo_datasource").db("theDatabase");
var theSeasons = db.seasons.aggregate( [
{ $match: { seasonStatus: "Active" } },
{ $project: {
"_id": 1, // 1: include this field, 0 exclude it, or convert field to another datatype
"seasonName" : "$name",
"seasonStartDateTime": { $dateToString: { format: "%m/%d/%Y", date: "$startDate" } } ,
"seasonEndDateTime": { $dateToString: { format: "%m/%d/%Y", date: "$endDate" } },
"materials":1 // this will include all the elements that make up the embedded documents.
}
}
] );
// this returns an array of structs with materials being a further array of structs.
seasonsArray = theSeasons.toArray();
return seasonsArray;
}
Generally pretty simple stuff. it returns an array of structs, with the _id field as an object and the Materials field as an array of structs, with each array item having an id field that’s a BSON object. So the question I have does anyone know how I can retrieve the value of the _id fields only and not their respective BSON objects?
Many thanks.spills
12/27/2024, 7:41 PMlarryclyons
12/30/2024, 2:00 PMspills
12/30/2024, 6:15 PMspills
12/30/2024, 6:17 PMlarryclyons
01/03/2025, 4:50 PMspills
01/05/2025, 1:42 AMlarryclyons
01/08/2025, 7:09 PM