Possible to programmatically detect datamodel changes in CloudCode?

I noticed the oplog response contains a data model hash https://docs.journeyapps.com/reference/backend-api/api-reference/oplog#application

Is there an easy way to read this hash from CloudCode, or do I need to make an API call to the oplog / backend API?

It’s possible to read the schema XML file from CloudCode, and then use something like sha.js to calculate the hash.

Here’s a TS snippet:

    import { TaskContext } from '@journeyapps/cloudcode';

    import * as fs from 'fs';
    import * as shajs from 'sha.js';

    export async function run(this: TaskContext) {
        const result = fs.readFileSync('./app/schema.xml').toString();

Hi Kobie

That would be beneficial for me too, except that I need to get the schema in JSON, the same format you would get in when making a datamodel API call. Thanks.

@martin: if you need to get the schema in JSON, have you tried accessing the built-in DB.schema object?