#Mongoose Object ID's not being able to be assigned

3 messages · Page 1 of 1 (latest)

junior sentinel
#
  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;
  }
#

Thats what my logic is this is what it says:

Type 'ObjectId' is missing the following properties from type 'ObjectId': auto, defaultOptions, OptionsConstructor, cast, and 18 more.ts(2740)

#

Mongoose Objects not being able to be assigned