How to use webiny-entity-mysql - 5 common examples

To help you get started, we’ve selected a few webiny-entity-mysql 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 / examples / api / src / import / users / import.js View on Github external
export default async () => {
    Entity.driver = new MySQLDriver({ connection });

    const authentication = new Authentication({
        identities: [{ identity: User }]
    });

    // Configure default storage
    const localDriver = new LocalDriver({
        directory: __dirname + "/storage",
        createDatePrefix: false,
        publicUrl: "https://cdn.domain.com"
    });

    const storage = new Storage(localDriver);

    // Register attributes
    registerSecurityAttributes(authentication);
github webiny / webiny-js / examples / api / src / import / users / import.js View on Github external
export default async () => {
    Entity.driver = new MySQLDriver({ connection });

    const authentication = new Authentication({
        identities: [{ identity: User }]
    });

    // Configure default storage
    const localDriver = new LocalDriver({
        directory: __dirname + "/storage",
        createDatePrefix: false,
        publicUrl: "https://cdn.domain.com"
    });

    const storage = new Storage(localDriver);

    // Register attributes
    registerSecurityAttributes(authentication);
github webiny / webiny-js / examples / api / src / configs / middleware.js View on Github external
expiresOn: req => addDays(new Date(), req.body.remember ? 30 : 1),
                                    apiMethod: {
                                        name: "Auth.User.Login",
                                        pattern: "/login-user"
                                    }
                                }
                            ]
                        }
                    ]
                }
            })
        ],
        // Entity layer
        entity: {
            // Instantiate driver with DB connection
            driver: new MySQLDriver({ connection }),
            // Configure entity attributes
            attributes: ({ bufferAttribute, fileAttributes, imageAttributes }) => {
                bufferAttribute();
                fileAttributes({
                    entity: File,
                    storage: new Storage(localDriver)
                });
                imageAttributes({
                    entity: Image,
                    processor: imageProcessor(),
                    quality: 90
                });
            }
        }
    })
};
github webiny / webiny-js / examples / cloud-api / src / app / middleware.js View on Github external
export default async () => {
    // Configure default storage
    const localDriver = new LocalDriver({
        directory: __dirname + "/../../storage",
        createDatePrefix: false,
        publicUrl: "http://localhost:9000/storage/"
    });

    api.configure({
        database: { connection },
        entity: {
            // Instantiate driver with DB connection
            driver: new MySQLDriver({ connection }),
            // Configure entity attributes
            attributes: ({
                /*                passwordAttribute,
                identityAttribute,
                bufferAttribute,*/
                fileAttributes,
                imageAttributes
            }) => {
                /*                identityAttribute();
                passwordAttribute();
                bufferAttribute();*/
                fileAttributes({
                    entity: File,
                    storage: new Storage(localDriver)
                });
                imageAttributes({
github webiny / webiny-js / examples / api / src / import / cms / import.js View on Github external
export default async () => {
    Entity.driver = new MySQLDriver({ connection });

    console.log("Importing data...");
    for (let i = 0; i < importData.length; i++) {
        const { entity, data } = await importData[i]();
        for (let j = 0; j < data.length; j++) {
            const obj = data[j];
            const instance = new entity();
            try {
                instance.populate(obj);
                await instance.save();
            } catch (e) {
                if (e.data) {
                    console.log(e.data.invalidAttributes);
                } else {
                    console.log(e);
                }

webiny-entity-mysql

A MySQL driver for entity layer.

MIT
Latest version published 5 years ago

Package Health Score

66 / 100
Full package analysis

Popular webiny-entity-mysql functions

Similar packages