Skip to content

Team/”Load from OJ“ 功能修改数据库 _id 相关报错的可能解决方案 #17

Description

@waylanguo-web

我发现在使用从 OJ 中导入队伍时,会有报错:

Image Image

简单阅读源码后,大致定位问题可能来自 fetcher.ts,293 行的这一段代码:

Image

Hydro 同步队伍时,把带 _id 的整条 team 直接塞进了 set,似乎是导致这个报错的原因。

Image
for (const team of teams) {
            const logo = resolvePublicAssetUrl(team.schoolLogo || team.logo || team.avatar, config.server);
            await this.ctx.db.teams.update({ id: team._id }, {
                $set: {
                    ...team,
                    ...logo && { logo },
                },
            }, { upsert: true });
        }

修改后问题也成功解决了:

Image Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions