I want to create a table with a map accepting string as key and any object as value (boolean, string, int, timestamp).
Is it possible ?
Thanks
Use the UPDATE command to insert values into the map. Append an element to the map by enclosing the key-value pair in curly brackets and using the addition (+) operator. cqlsh> UPDATE cycling.
A map is a name and a pair of typed values. Using the map type, you can store timestamp-related information in user profiles. Each element of the map is internally stored as one Cassandra column that you can modify, replace, delete, and query.
The tuple data type holds fixed-length sets of typed positional fields. Use a tuple as an alternative to a user-defined type. A tuple can accommodate many fields (32768), more than can be prudently used. Typically, create a tuple with a few fields.
Currently, no, keys and values in a map must be of a known CQL type. There is a request for "dynamic types", but nobody has worked on it so far.
Any object isn't possible. You can create user defined types but this type isn't dynamic: https://docs.datastax.com/en/cql/3.1/cql/cql_reference/cqlRefcreateType.html
You can parse your object as json and this json as string. You can insert this string in a text column.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With