async create(location: Location): Promise<Location> {
const createdLocation = new this.locationModel(location);
const savedLocation = await createdLocation.save();
// Create a Baptism object for the new location
const baptism = new this.baptismModel({
locationInfo: savedLocation._id, // Assuming locationInfo refers to the Location's ObjectId
registrationLink: 'your-registration-link',
});
const savedBaptism = await baptism.save();
savedLocation.departments.baptisms = savedBaptism._id;
// Assign the ID of the newly created Baptism to the Location
await savedLocation.save();
return savedLocation;
}
#Mongoose Object ID's not being able to be assigned
3 messages · Page 1 of 1 (latest)