Improve type definitions
This commit is contained in:
parent
76edcdbe45
commit
b679163d01
7 changed files with 110 additions and 73 deletions
|
|
@ -9,6 +9,7 @@ import * as mongo from 'mongodb';
|
|||
import db from '../../db/mongodb';
|
||||
import { ICollection } from 'monk';
|
||||
import Logger from '../../misc/logger';
|
||||
import { Schema } from '../../prelude/schema';
|
||||
|
||||
const logger = new Logger('chart');
|
||||
|
||||
|
|
@ -346,3 +347,18 @@ export default abstract class Chart<T extends Obj> {
|
|||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
export function convertLog(logSchema: Schema): Schema {
|
||||
const v: Schema = JSON.parse(JSON.stringify(logSchema)); // copy
|
||||
if (v.type === 'number') {
|
||||
v.type = 'array';
|
||||
v.items = {
|
||||
type: 'number'
|
||||
};
|
||||
} else if (v.type === 'object') {
|
||||
for (const k of Object.keys(v.properties)) {
|
||||
v.properties[k] = convertLog(v.properties[k]);
|
||||
}
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue