How to use the webiny-data-extractor.get function in webiny-data-extractor

To help you get started, we’ve selected a few webiny-data-extractor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github webiny / webiny-js / packages-utils / webiny-model / src / model.js View on Github external
async toJSON(fields: string): Promise {
        return await extractor.get(this, fields, {
            onRead: async (data, key) => {
                // Key can accept ":" separated arguments, so we have to make sure those are parsed.
                const received = this.__parseKeyParams(key);

                if (typeof data.getAttribute === "function") {
                    if (!data.getAttribute(received.key)) {
                        return [received.key];
                    }
                    return [
                        received.key,
                        await data.getAttribute(received.key).getJSONValue(...received.arguments)
                    ];
                }
                return [received.key, await data[received.key]];
            }
        });

webiny-data-extractor

A small library for easy async data extraction, using dot and square brackets notation.

MIT
Latest version published 5 years ago

Package Health Score

66 / 100
Full package analysis

Popular webiny-data-extractor functions

Similar packages