3logic / apollo-cassandra

A basic ORM for Cassandra
GNU Lesser General Public License v3.0
48 stars 14 forks source link

Static columns #17

Open theRemix opened 9 years ago

theRemix commented 9 years ago

allow columns to be defined as static, example schema:

{
    fields:{
        username: "text",
        id: {
            "type":"uuid",
            "default": {"$db_function": "uuid()"}
        },
        name:{
            "type":"text",
            "static":true
        },
        surname:{
            "type":"text",
            "static":true
        },
        favorites:{
            "type":"text",
            "static":false
        },
        likes:"text",
    },
    key:[["username"],"id"]
}

which would build this table

CREATE TABLE tests.teststaticfields (
    username text,
    id uuid,
    favorites text,
    likes text,
    name text static,
    surname text static,
    PRIMARY KEY (username, id)
) WITH CLUSTERING ORDER BY (id ASC)
...

and produce these columns

 keyspace_name | columnfamily_name | column_name | component_index | index_name | index_options | index_type | type           | validator
---------------+-------------------+-------------+-----------------+------------+---------------+------------+----------------+------------------------------------------
         tests |  teststaticfields |   favorites |               1 |       null |          null |       null |        regular | org.apache.cassandra.db.marshal.UTF8Type
         tests |  teststaticfields |          id |               0 |       null |          null |       null | clustering_key | org.apache.cassandra.db.marshal.UUIDType
         tests |  teststaticfields |       likes |               1 |       null |          null |       null |        regular | org.apache.cassandra.db.marshal.UTF8Type
         tests |  teststaticfields |        name |               1 |       null |          null |       null |         static | org.apache.cassandra.db.marshal.UTF8Type
         tests |  teststaticfields |     surname |               1 |       null |          null |       null |         static | org.apache.cassandra.db.marshal.UTF8Type
         tests |  teststaticfields |    username |            null |       null |          null |       null |  partition_key | org.apache.cassandra.db.marshal.UTF8Type