Search code examples
cassandraexpress-cassandra

express-cassandra invalidates uuid when generated uuid package


I have the following field in my cassandra model:

        user: {
            type:"uuid",
            rule:{
                required:true,
            }
        },

However, whenever I try to save a data, I get the following error: apollo.model.validator.invalidvalue: Invalid Value: "**uuid generated here***" for Field: sender (Type: uuid) I have used uuid to generate it

I have tried generating uuid through the package,even hardcoded a uuid but still the error persists.


Solution

  • Express-cassandra translates datatypes from JS to Cassandra. You may try to use the built-in datatype functions described here:

    https://express-cassandra.readthedocs.io/en/latest/datatypes/

    A built in function to generate uuids is available. If for some reason, another package needs to be used for generating uuids and that generates a uuid as string, then you can convert that using the models.uuidFromString(str) function as described in the doc.