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:
@@ -16,7 +16,6 @@ class ClanService {
|
||||
.skip(Number(offset))
|
||||
.limit(Number(limit))
|
||||
.sort({ title: 'asc' })
|
||||
.populate('author')
|
||||
.exec(),
|
||||
HWClan.count(query).exec()
|
||||
]).then(function (results) {
|
||||
@@ -31,7 +30,6 @@ class ClanService {
|
||||
|
||||
static async getClanById(id) {
|
||||
return HWClan.findOne({ id: id })
|
||||
.populate('author')
|
||||
.then(function (clan) {
|
||||
if (!clan) {
|
||||
return null;
|
||||
@@ -42,7 +40,6 @@ class ClanService {
|
||||
|
||||
static async getClanByTitle(title) {
|
||||
return HWClan.findOne({ title: title })
|
||||
.populate('author')
|
||||
.then(function (clan) {
|
||||
if (!clan) {
|
||||
return null;
|
||||
|
||||
@@ -16,7 +16,6 @@ class MemberService {
|
||||
.skip(Number(offset))
|
||||
.limit(Number(limit))
|
||||
.sort({ name: 'asc' })
|
||||
.populate('author')
|
||||
.exec(),
|
||||
HWMember.count(query).exec()
|
||||
]).then(function (results) {
|
||||
@@ -31,7 +30,6 @@ class MemberService {
|
||||
|
||||
static async getMemberById(id) {
|
||||
return HWMember.findOne({ id: id })
|
||||
.populate('author')
|
||||
.then(function (member) {
|
||||
if (!member) {
|
||||
return null;
|
||||
@@ -42,7 +40,6 @@ class MemberService {
|
||||
|
||||
static async getMemberByName(name) {
|
||||
return HWMember.findOne({ name: name })
|
||||
.populate('author')
|
||||
.then(function (member) {
|
||||
if (!member) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user