fix(skydive): migrate author field from ObjectId to UUID string
- Register SkydiverProfile model in mysql.js (fixes startup crash on association)
- Replace $toObjectId with direct string match in all 12 aggregation queries
- Guard toJSONFor on all Mongo models to fall back to MySQL user.toProfileJSONFor()
when author is a UUID string (restores username/image in API responses)
- Pass user to toJSONFor() everywhere instead of null
- Remove dead .populate('author') calls (author: String has no ref)
- Fix ownership check in /last route: compare author string to req.payload.id
instead of the now-absent author.username property
This commit is contained in:
@@ -26,7 +26,9 @@ DropzoneSchema.methods.toJSONFor = function(user){
|
||||
oaci: this.oaci,
|
||||
createdAt: this.createdAt,
|
||||
updatedAt: this.updatedAt,
|
||||
author: this.author.toProfileJSONFor(user)
|
||||
author: this.author && typeof this.author.toProfileJSONFor === 'function'
|
||||
? this.author.toProfileJSONFor(user)
|
||||
: (user && typeof user.toProfileJSONFor === 'function' ? user.toProfileJSONFor() : this.author ?? null)
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user