Add simple import of data from non-core asphyxia

This commit is contained in:
cracrayol
2020-12-12 23:44:01 +01:00
parent 10207c1044
commit 7fcd3024c1
5 changed files with 95 additions and 28 deletions
+33
View File
@@ -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
}
}
}
);
};