Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSONB support #23

Open
beautyfree opened this issue Oct 23, 2024 · 1 comment
Open

JSONB support #23

beautyfree opened this issue Oct 23, 2024 · 1 comment

Comments

@beautyfree
Copy link

I get error cannot assign to field \"1\" of column \"content\" because its type jsonb is not a composite type when i try to use jsonb field of postgresql database

related: SoftwareBrothers/adminjs#1690

@roma-glushko
Copy link

Have got the same error when trying to use key-value property type for a JSONB field.

What seems to help me is to use this before hook to convert the property value as a JSON string:

const encodePropertyValue = async (request) => {
        if (request.payload) {
            const payload = request.payload
            const propertyValueObject = flat.get(payload, property)

            request.payload = {
                ...flat.filterOutParams(payload, [property]),
                [property]: propertyValueObject ? JSON.stringify(propertyValueObject) : '{}',
            }
        }

        return request;
    }
actions: {
            edit: {
                before: [encodePropertyValue],
            },
            new: {
                before: [encodePropertyValue],
            },
        },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants