mirror of
https://github.com/asphyxia-core/plugins.git
synced 2026-10-09 23:58:12 +03:00
Add simple import of data from non-core asphyxia
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { Profile } from "../models/profile";
|
||||
import { Scores } from "../models/scores";
|
||||
|
||||
export const importPnmData = async (data: {
|
||||
refid: string;
|
||||
profile: string;
|
||||
scores: string;
|
||||
}) => {
|
||||
const profile = JSON.parse(data.profile);
|
||||
const scores = JSON.parse(data.scores);
|
||||
|
||||
await DB.Update<Profile>(
|
||||
data.refid,
|
||||
{ collection: 'profile' },
|
||||
{
|
||||
$set: {
|
||||
...profile
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
await DB.Upsert<Scores>(
|
||||
data.refid,
|
||||
{ collection: 'scores' },
|
||||
{
|
||||
$set: {
|
||||
scores: {
|
||||
...scores
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user