async list(request) {
        const query = request.query();


        if (query.shard) {
            // return the data for one given shard

            if (!type.string(query.offset)) request.response().status(400).send(`Missing offset query parameter!`);
            else if (!type.string(query.limit)) request.response().status(400).send(`Missing limit query parameter!`);
            else {


                // get the viable data versions. do this in two steps,
                // postgres has difficulties optimizing this if we're
                // getting everything in one query
                const dataGroups = await this.db.dataGroup().getShard({
                    identifier: query.shard
                }).raw().find();


                // get the actual data
                const data = await this.db.data('*', {
                    id_dataGroup: this.db.getORM().in(dataGroups.map(g => g.id))
                }).order('id')
                  .offset(parseInt(query.offset, 10))
                  .limit(parseInt(query.limit, 10))
                  .getDataVersion('identifier')
                  .fetchDataVersionStatus('identifier')
                  .getDataSet('identifier')
                  .raw().find();

                return data.map((data) => ({
                    ...data.data,
                    dataVersionId: data.dataVersion.id,
                    dataSetId: data.dataVersion.dataSet.id,
                    datasetIdentifier: data.dataVersion.dataSet.identifier,
                    dataVersionStatusIdentifier: data.dataVersion.dataVersionStatus.identifier,
                }));
            }
        } else throw new Error('not implemented (missing filter)');
    }
/**
    * returns data fro a given filter
    */
returns data fro a given filter
returns data fro a given filter
async list(request) {
        const query = request.query();
        if (query.shard) {
            if (!type.string(query.offset)) request.response().status(400).send(`Missing offset query parameter!`);
            else if (!type.string(query.limit)) request.response().status(400).send(`Missing limit query parameter!`);
            else {
                const dataGroups = await this.db.dataGroup().getShard({
                    identifier: query.shard
                }).raw().find();
                const data = await this.db.data('*', {
                    id_dataGroup: this.db.getORM().in(dataGroups.map(g => g.id))
                }).order('id')
                  .offset(parseInt(query.offset, 10))
                  .limit(parseInt(query.limit, 10))
                  .getDataVersion('identifier')
                  .fetchDataVersionStatus('identifier')
                  .getDataSet('identifier')
                  .raw().find();
                return data.map((data) => ({
                    ...data.data,
                    dataVersionId: data.dataVersion.id,
                    dataSetId: data.dataVersion.dataSet.id,
                    datasetIdentifier: data.dataVersion.dataSet.identifier,
                    dataVersionStatusIdentifier: data.dataVersion.dataVersionStatus.identifier,
                }));
            }
        } else throw new Error('not implemented (missing filter)');
    }
async list ( request ) { const query = request . query ( ) ; if ( query . shard ) { if ( ! type . string ( query . offset ) ) request . response ( ) . status ( 400 ) . send ( ` ` ) ; else if ( ! type . string ( query . limit ) ) request . response ( ) . status ( 400 ) . send ( ` ` ) ; else { const dataGroups = await this . db . dataGroup ( ) . getShard ( { identifier : query . shard } ) . raw ( ) . find ( ) ; const data = await this . db . data ( '*' , { id_dataGroup : this . db . getORM ( ) . in ( dataGroups . map ( g => g . id ) ) } ) . order ( 'id' ) . offset ( parseInt ( query . offset , 10 ) ) . limit ( parseInt ( query . limit , 10 ) ) . getDataVersion ( 'identifier' ) . fetchDataVersionStatus ( 'identifier' ) . getDataSet ( 'identifier' ) . raw ( ) . find ( ) ; return data . map ( ( data ) => ( { ... data . data , dataVersionId : data . dataVersion . id , dataSetId : data . dataVersion . dataSet . id , datasetIdentifier : data . dataVersion . dataSet . identifier , dataVersionStatusIdentifier : data . dataVersion . dataVersionStatus . identifier , } ) ) ; } } else throw new Error ( 'not implemented (missing filter)' ) ; }
returns data fro a given filter
returns data fro a given filter
// return the data for one given shard // get the viable data versions. do this in two steps, // postgres has difficulties optimizing this if we're // getting everything in one query // get the actual data