{"id":23111939,"url":"https://github.com/jcthomas4214/cassmask","last_synced_at":"2026-05-03T16:31:28.683Z","repository":{"id":57194839,"uuid":"81310935","full_name":"JCThomas4214/CassMask","owner":"JCThomas4214","description":"A ReactiveX Observable driven Apache Cassandra ORM for Node Applications","archived":false,"fork":false,"pushed_at":"2017-08-11T03:24:05.000Z","size":235,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-10T09:17:16.517Z","etag":null,"topics":["apache","cassandra","cassandra-cql","cassandra-orm","cql","library","nodejs","observables","orm","orm-library","rxjs","schema"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JCThomas4214.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-08T09:20:23.000Z","updated_at":"2021-03-18T17:05:40.000Z","dependencies_parsed_at":"2022-09-16T05:21:29.928Z","dependency_job_id":null,"html_url":"https://github.com/JCThomas4214/CassMask","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JCThomas4214%2FCassMask","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JCThomas4214%2FCassMask/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JCThomas4214%2FCassMask/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JCThomas4214%2FCassMask/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JCThomas4214","download_url":"https://codeload.github.com/JCThomas4214/CassMask/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247097972,"owners_count":20883127,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apache","cassandra","cassandra-cql","cassandra-orm","cql","library","nodejs","observables","orm","orm-library","rxjs","schema"],"created_at":"2024-12-17T02:13:40.439Z","updated_at":"2026-05-03T16:31:28.593Z","avatar_url":"https://github.com/JCThomas4214.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n[![Travis Build](https://travis-ci.org/JCThomas4214/CassMask.svg?branch=master)](https://travis-ci.org/JCThomas4214/CassMask)\n[![npm version](https://img.shields.io/npm/v/cassmask.svg)](https://www.npmjs.com/package/cassmask)\n\n# CassMask (tested with Apache-Cassandra 3.x)\n\n#### DataTypes Thoroughly tested\n\n+ TIMEUUID\n+ UUID\n+ TIMESTAMP\n+ INT\n+ TEXT\n\n#### DataTypes not tested (will probably work)\n\n+ ASCII\n+ BIGINT\n+ SMALLINT\n+ TINYINT\n+ VARCHAR\n+ VARINT\n+ FLOAT\n+ DOUBLE\n+ DECIMAL\n+ BOOLEAN\n\n#### DataTypes not tested (will probably NOT work)\n\n+ BLOB\n+ INET\n\n#### DataTypes that WILL not work\n\n+ COUNTER\n+ MAP \n+ SET \n+ LIST \n+ User Defined Data types\n\n## Table of Contents\n\n1. [Why Observables?](#whyObservables)\n   1. [Everything is an Observable.](#eqObservable)\n2. [The Entity](#entityObject)\n   1. [Important Limitations](#eIssues)\n   2. [Entity Example](#entityExample)\n3. [Validation](#validation)\n4. [Event Hooks](#eventHooks)\n   1. [Socket.io example](#sioEx)\n5. [CassMask API](#cassmaskapi)\n   1. [connect](#connect)\n   2. [model](#model)\n6. [Model API](#modelapi)\n   1. [seam](#seam)\n   2. [find](#find)\n   3. [findOne](#findOne)\n   4. [findById](#findById)\n   5. [create](#create)\n   6. [update](#update)\n   7. [remove](#remove)\n   8. [post](#post)\n   9. [pre](#pre)\n   10. [methods](#methods)\n   11. [createIndex](#createIndex)\n7. [Entity API](#entityAPI)\n   1. [constructor](#entityconstructor)\n   2. [isEmpty](#entityisempty)\n   3. [merge](#entitymerge)\n   4. [save](#entitysave)\n   5. [remove](#entityremove)\n8. [TODO](#TODO)\n\n## Quick Start\n\n```sh\n$ npm install cassmask\n```\n\nConnect to Cassandra with a [ClientOptions](http://docs.datastax.com/en/developer/nodejs-driver/3.2/api/type.ClientOptions/) object.\n\n```ts\nimport { connect } from 'cassmask';\n\n// ClientOptions Object\nconst config = {\n  contactPoints: ['127.0.0.1'],\n  protocolOptions: { port: 9042 },\n  queryOptions: { consistency: 1 },\n  keyspace: 'demo-space'\n};\n\nconnect(config, (err, result) =\u003e {\n  // callback after connection\n});\n```\n\nCreate a model ([click here](https://github.com/JCThomas4214/CassMask/wiki/Schema) for a ES5 example)\n\n```ts\nimport * as cassmask from 'cassmask';\nimport { toTimeStamp, now, uuid } from 'cassmask';\n\n// An interface for your Schema is not necessary but\n// it enables Typescript to type-check the key-value paires\n// placed into cassmask's query functions\ninterface IModelSchema extends cassmask.ISchema {\n  col1?: cassmask.UUID;\n  col2?: cassmask.TIMEUUID;\n  col3?: cassmask.TIMESTAMP;\n  col4?: cassmask.TEXT;\n  col5?: cassmask.INT;  \n}\n\nclass ModelSchema extends cassmask.Schema {\n  // declare schema type values\n  col1 = {\n    type: cassmask.UUID,\n    default: uuid()\n  };\n  col2 = {\n    type: cassmask.TIMEUUID,\n    default: now()\n  };\n  col3 = {\n    type: cassmask.TIMESTAMP,\n    default: toTimeStamp(now())\n  };\n  col4 = {\n    type: cassmask.TEXT,\n    required: true\n  };\n  col5 = {\n    type: cassmask.INT,\n    required: 'Col5 must be present!!'\n  };\n  // Primary Keys (Partition \u0026 Clustering Column)\n  keys = ['col1', 'col2'];\n\n  constructor() {\n    super();\n  }\n\n  // Define validate_[column name] function to create\n  //    a validate function for that key\n\n  validate_col4(col4, next) {\n    if(col4.length \u003e= 5) next();\n    else next('col4 is not long enough!');\n  }\n\n  validate_col5(col5, next) {\n    if(col5 \u003e= 5) next();\n    else next('col5 value is not large enough!');\n  }\n\n  // Define pre_create, pre_update, pre_remove, pre_find\n  //    post_create, post_update, post_remove, post_find\n  //    functions to set hook events\n\n  pre_create(next, err) {\n    this.col4 += ' test pre hook!';\n    next();\n  }\n\n  // Other defined functions will be integrated into Entity scope\n}\n\nexport default cassmask.model\u003cIModelSchema\u003e('Model', new ModelSchema());\n```\n\nFind, create, remove, update...\n\n```ts\nimport Model from 'path/to/model.ts';\n\nlet holder = [];\n\n/*\n  Existing rows in Model Table\n    { col1: '[uuid]', col2: '[timeuuid]', col3: '[created time]', col4: 'before1 test pre hook!', col5: 6 }\n    { col1: '[uuid]', col2: '[timeuuid]', col3: '[created time]', col4: 'before2 test pre hook!', col5: 7 }\n    { col1: '[uuid]', col2: '[timeuuid]', col3: '[created time]', col4: 'before3 test pre hook!', col5: 8 }\n    { col1: '[uuid]', col2: '[timeuuid]', col3: '[created time]', col4: 'before4 test pre hook!', col5: 9 }\n\n*/\n\nModel.create([{\n  col4: 'test1',\n  col5: 49\n}, {\n  col4: 'test2',\n  col5: 23\n}, {\n  col4: 'test3',\n  col5: 97\n}, {\n  col4: 'test4',\n  col5: 57\n}]).remove([{\n  col1: 'generated uuid', // before2\n  col2: 'generated timeuuid'\n}, {\n  col1: 'generated uuid', // before4\n  col2: 'generated timeuuid'\n}]).find().seam().subscribe( // Every next argument will be an Entity object for every query executed\n  x =\u003e holder.push(x),\n  err =\u003e console.log(err),\n  () =\u003e {}\n);\n\n/*  \n  Model Table\n    { col1: '[uuid]', col2: '[timeuuid]', col3: '[created time]', col4: 'before1 test pre hook!', col5: 6 }\n    { col1: '[uuid]', col2: '[timeuuid]', col3: '[created time]', col4: 'before3 test pre hook!', col5: 8 }\n    { col1: '[uuid]', col2: '[timeuuid]', col3: '[created time]', col4: 'test1 test pre hook!', col5: 49 }\n    { col1: '[uuid]', col2: '[timeuuid]', col3: '[created time]', col4: 'test2 test pre hook!', col5: 23 }\n    { col1: '[uuid]', col2: '[timeuuid]', col3: '[created time]', col4: 'test3 test pre hook!', col5: 97 }\n    { col1: '[uuid]', col2: '[timeuuid]', col3: '[created time]', col4: 'test4 test pre hook!', col5: 57 }\n*/\n```\n\n\u003ca name=\"whyObservables\"\u003e\u003c/a\u003e\n\n# Why Observables?\n\nObservables are fancy promises that operate under event streams which give us opportunities to seam these streams together and filter results. For more information about observables and the [ReactiveX](http://reactivex.io/) RxJS library [click here](http://reactivex.io/rxjs/).\n\n\u003ca name=\"eqObservable\"\u003e\u003c/a\u003e\n\n## Everything is an Observable.\n\nIn CassMask every query, event hook, and validation is executed inside an observable and it uses RxJS [concatenate](http://reactivex.io/documentation/operators/concat.html) to seam them together to ensure proper sequence on subscribe.\n\n\u003ca name=\"eventSeq\"\u003e\u003c/a\u003e\n\n## Event Sequence Per Query Function/Query Object\n\n| REQUIRE -\u003e | VALIDATION -\u003e | PRE -\u003e | QUERY -\u003e | POST |\n|:-------:|:-------------:|:------:|:--------:|:----:|\n| condition | function | function | function | function |\n\n_NOTE: require is create specific and validation is create/update specific_\n\n\u003ca name=\"entityObject\"\u003e\u003c/a\u003e\n\n## The Entity.\n\nOnce a query is executed in the stream an Entity object (or array of Entities) will be passed as the observer.next() argument giving the developer an opportunity to interact with it. The Entity object gives us access to a couple useful functions, save() and remove(). Save() will take the current attributes of the Entity and create a query string to UPDATE (INSERT) a row in the table. Similar to save(), remove() will take the current attributes and DELETE from the table. An Entity (or array of Entities) will be created from either the response row array from the corresponding query, or if the query does not respond with data (UPDATE, INSERT, DELETE), will be created from the key value pairs that were used in the original Schema query function.\n\n\u003ca name=\"eIssues\"\u003e\u003c/a\u003e\n\n### Important Limitations.\n\nIn order to use CassMask well, it's important to understand CQL. If the query does not respond with data (SELECT) then a particular Entity instance may not have the attributes to INSERT, UPDATE, and/or DELETE rows in a table. Specifically the necessary [Partition Key](https://docs.datastax.com/en/cql/3.3/cql/cql_using/useSimplePrimaryKeyConcept.html#useSimplePrimaryKeyConcept) and [Clustering Columns](https://docs.datastax.com/en/cql/3.3/cql/cql_using/useCompoundPrimaryKey.html) to obtain the specificity required to UPDATE/DELETE a certain row. The remove() and update() querying functions in your Schema object will require your Primary Keys in order to function correctly so the problem is not as apparent as create() where certain keys may be generated on the database itself (uuid, timeuuid, timestamp, etc..).\n\nAn [event hook](#eventHooks) could be used to protentially solve this delema. We could hook into the 'create' event and execute a SELECT query to find the most recently appended row and pass this object through the observer.next() argument, which could be used in your endpoint. This is not done automatically because of the level of involvement required to create tables with a certain clustering order.\n\n\u003ca name=\"entityExample\"\u003e\u003c/a\u003e\n\n### Entity Example\n\n```ts\nlet holder = [];\n\n// findOne with no argument will find the first row in the\n// table and pass an Entity with the found row to next()\n\n// find with no argument will find the all rows in the\n// table and pass an Entity with the found rows to next()\nModel.findOne().find().seam().subscribe( // two queries are executed and two next() functions are called\n  model =\u003e holder.push(model),\n  err =\u003e console.log(err),\n  () =\u003e {\n    holder[0].col4 = 'awesome_example'; // index 0 is the findOne query argument\n    holder[0].col5 = 49;\n\n    /*  \n      Model Table after holder[0].save() but before holder[1] interaction\n        { col1: '[uuid]', col2: '[timeuuid]', col3: '[created time]', col4: 'awesome_example', col5: 49 }\n        { col1: '[uuid]', col2: '[timeuuid]', col3: '[created time]', col4: 'before3', col5: 2 }\n        { col1: '[uuid]', col2: '[timeuuid]', col3: '[created time]', col4: 'test1', col5: 49 }\n        { col1: '[uuid]', col2: '[timeuuid]', col3: '[created time]', col4: 'test2', col5: 23 }\n        { col1: '[uuid]', col2: '[timeuuid]', col3: '[created time]', col4: 'test3', col5: 97 }\n        { col1: '[uuid]', col2: '[timeuuid]', col3: '[created time]', col4: 'test4', col5: 57 }\n    */  \n\n    holder[0].save().subscribe(model =\u003e {\n\n      holder[1].forEach(entity =\u003e { // holder[1] is an array of Entity Object from find()\n        entity.col4 = 'awesome_example2';\n        entity.col5 = 99;\n        entity.save().subscribe(x =\u003e {}, err =\u003e console.log(err));\n      });\n\n    }, err =\u003e console.log(err));\n  });\n\n/*  \n  Model Table after holder[1] interaction\n    { col1: '[uuid]', col2: '[timeuuid]', col3: '[created time]', col4: 'awesome_example2', col5: 99 }\n    { col1: '[uuid]', col2: '[timeuuid]', col3: '[created time]', col4: 'awesome_example2', col5: 99 }\n    { col1: '[uuid]', col2: '[timeuuid]', col3: '[created time]', col4: 'awesome_example2', col5: 99 }\n    { col1: '[uuid]', col2: '[timeuuid]', col3: '[created time]', col4: 'awesome_example2', col5: 99 }\n    { col1: '[uuid]', col2: '[timeuuid]', col3: '[created time]', col4: 'awesome_example2', col5: 99 }\n    { col1: '[uuid]', col2: '[timeuuid]', col3: '[created time]', col4: 'awesome_example2', col5: 99 }\n*/\n\n```\n\u003c!---\n\u003ca name=\"batching\"\u003e\u003c/a\u003e\n\n## Batching!\n\nBatching is not always practical in Cassandra because of how it partitions the data to Nodes/SSTables. Batching is best practice if and only if the INSERTS, UPDATES, and DELETES are for a single partition.\n\nIn CassMask batching is currently only availiable per function basis and is off by default. If you would like to enable it, simply pass in a Object with batch = true as the second argument.\n\n```ts\n// Parititon key = catagory\nModel.remove().create([{\n    catagory: 'cloud',\n    id: now(),\n    name: 'SocketIO',\n    xcoor: 52,\n    ycoor: 15\n  }, {\n    catagory: 'cloud',\n    id: now(),\n    name: 'Cassandra',\n    xcoor: 35,\n    ycoor: 35\n  }, {\n    catagory: 'cloud',\n    id: now(),\n    name: 'Angular 2',\n    xcoor: 10,\n    ycoor: 65\n  }], { batch: true }).seam().subscribe(x =\u003e {}, err =\u003e console.log(err));\n```\n\n\u003ca name=\"tcbBatching\"\u003e\u003c/a\u003e\n\n### Things to consider before batching.\n\nWhen batching, multiple queries are condenced into a single query with multiple statements. If you would like event driven features you will need to keep in mind that the CassMask Event API will only be triggered (depending on the hook) once per query response. Depending on your use case an emit per INSERT, UPDATE, and/or DELETE may be preferable.\n--\u003e\n\u003ca name=\"validation\"\u003e\u003c/a\u003e\n\n## Validation\n\nValidation in CassMask can be configured per schema property basis. Configure a validation function to pass an error message and stop the event stream when conditions are not met.\n\n### Valiation Example ([click here](https://github.com/JCThomas4214/CassMask/wiki/Validation) for an ES5 example)  \n\n```ts\ninterface IModelSchema extends cassmask.ISchema {\n  id?: cassmask.UUID;\n  name?: cassmask.TEXT;\n  points?: cassmask.INT;\n}\n\nclass ModelSchema extends cassmask.Schema {\n  // declare schema type values\n  id = {\n    type: cassmask.UUID,\n    default: uuid()\n  };\n  name = {\n    type: cassmask.TEXT,\n    required: 'Must have name!'\n  };\n  points = cassmask.INT;\n  // Primary Keys (Partition \u0026 Clustering Column)\n  keys = ['id', 'name'];\n\n  constructor() {\n    super();\n  }\n\n  // Define validate_[column name] function to create\n  //    a validate function for that key\n\n  validate_name(name, next) {\n    if(name.length \u003e= 5) next();\n    else next('name is not long enough!');\n  }\n}\n\nexport default cassmask.model\u003cIModelSchema\u003e('Model', new ModelSchema());\n```\n\n\u003ca name=\"eventHooks\"\u003e\u003c/a\u003e\n\n## Event Hooks\n\nIn CassMask there are PRE and POST event hooks for 'create', 'update', 'remove', and 'find'. These hooks are embedded inside each Entity (Instance) scope and they can be used to interact with the Entity object in the stream before/after a corresponding query execution/response.\n\n\u003ca name=\"sioEx\"\u003e\u003c/a\u003e\n\n### Socket.io example\n\nevents.ts\n\n```ts\nimport Model from './path/to/model.ts';\n\nlet EventEmitter = require('events').EventEmitter;\nlet ModelEvents = new EventEmitter();\n\n// Set max event listeners (0 == unlimited)\nModelEvents.setMaxListeners(0);\n\n/*\n  The lastEntity; for create(), update(), and remove(): Entity object that was originally passed into the query\n    for find() and findOne(): the rows found in the table\n  the next; this is a callback that expects zero or one argument.\n    callback will call observer next() and complete() functions\n    argument will be passed into next()\n  The client; this is the cassandra client, which can be used to execute additional queries\n\n */\nModel.post('create', function(next, err) {\n  // callback code goes here\n\n  Model.Events.emit('create', this);\n\n  next(this);\n});\n\nexport default ModelEvents;\n\n```\n\nsocket.ts\n\n```ts\n/**\n * Broadcast updates to client when the model changes\n */\n\nimport ModelEvents from './path/to/events.ts';\n\n// Model events to emit\nlet events = ['create'];\n\nfunction modelRegister(socket) {\n  // Bind model events to socket events\n  for (let i = 0, eventsLength = events.length; i \u003c eventsLength; i++) {\n    let event = events[i];\n    let listener = createListener('Model:' + event, socket);\n\n    // the Emitter will listen for changes in the model\n    ModelEvents.on(event, listener);\n    // when a disconnect comes from the socket then remove the listener\n    socket.on('disconnect', removeListener(event, listener));\n  }\n}\n\n// create listener funtion\nfunction createListener(event, socket) {\n  return function(row) {\n    socket.emit(event, row);\n  };\n}\n\n// remove listener function\nfunction removeListener(event, listener) {\n  return function() {\n    ModelEvents.removeListener(event, listener);\n  };\n}\n\nexport default modelRegister;\n```\n\nexecute modelRegister(socket) in your socketio.config onConnect function\n\n\u003ca name=\"cassmaskapi\"\u003e\u003c/a\u003e\n\n## CassMask API\n\n\u003ca name=\"connect\"\u003e\u003c/a\u003e\n\n#### [connect](https://github.com/JCThomas4214/CassMask/blob/master/index.ts)(config: [ClientOptions](http://docs.datastax.com/en/developer/nodejs-driver/3.2/api/type.ClientOptions/), cb: Function): void\n\n+ connects to the cassandra nodes\n+ cb function to be fired once connection sring returns\n\n\u003ca name=\"model\"\u003e\u003c/a\u003e\n\n#### [model](https://github.com/JCThomas4214/CassMask/blob/master/index.ts)(tableName: string, schema: Schema, indexes?: Array\\\u003cstring | Array\\\u003cstring\\\u003e\\\u003e): Model\n\n+ creates a Model object with querying capabilities \n+ indexes is an array of secondary indexes you can create for this model's table\n   + NOTE: to change/add the indexes you will need to drop the table for cassmask to create it again\n\n\n\u003ca name=\"modelapi\"\u003e\u003c/a\u003e\n\n## Model API\n\n\u003ca name=\"seam\"\u003e\u003c/a\u003e\n\n#### [seam](https://github.com/JCThomas4214/CassMask/blob/master/libs/seam.ts)(): Rx.Observable\\\u003cany\\\u003e\n\n+ returns single concatenated observables\n\n\u003ca name=\"find\"\u003e\u003c/a\u003e\n\n#### [find](https://github.com/JCThomas4214/CassMask/blob/master/libs/find.ts)(items?: Object, opts?: [FindOptions](#findoptions)): Schema\n\n+ first argument can be empty or an object\n  + If no arguments or empty object, will SELECT all rows in the table\n+ first argument should contain the columns for the WHERE clause\n  + columns should be in the same order as the primary keys\n+ second argument is a find options object\n  + options.attributes: Array\u003cstring\u003e | Object, columns to be included in the SELECT response\n    + if attributes is an object, exclude: Array\u003cstring\u003e will exclude columns from the SELECT response\n+ query will return an array of object or a single object\n\n\u003ca name=\"findOne\"\u003e\u003c/a\u003e\n\n#### [findOne](https://github.com/JCThomas4214/CassMask/blob/master/libs/findOne.ts)(items?: Object, opts?: [FindOptions](#findoptions)): Schema\n\n+ first argument can be empty or an object\n  + If no arguments or empty object, will SELECT the first row in the table\n+ first argument should contain the columns for the WHERE clause\n  + columns should be in the same order as the primary keys\n+ second argument is a find options object\n  + options.attributes: Array\u003cstring\u003e | Object, columns to be included in the SELECT response\n    + if attributes is an object, exclude: Array\u003cstring\u003e will exclude columns from the SELECT response\n+ query will return a single object\n\n\u003ca name=\"findById\"\u003e\u003c/a\u003e\n\n#### [findById](https://github.com/JCThomas4214/CassMask/blob/master/libs/findById.ts)(id: string, opts? [FindOptions](#findoptions)): Schema\n\n+ first argument must be an id\n+ second argument is a find options object\n  + options.attributes: Array\u003cstring\u003e | Object, columns to be included in the SELECT response\n    + if attributes is an object, exclude: Array\u003cstring\u003e will exclude columns from the SELECT response\n+ query will return a single or array of objects depending schema design\n\n\u003ca name=\"create\"\u003e\u003c/a\u003e\n\n#### [create](https://github.com/JCThomas4214/CassMask/blob/master/libs/create.ts)(items: Object | Array\\\u003cObject\\\u003e, opts?: [SchemaOptions](#schemaoptions)): Schema\n\n+ first argument can be an object or array of objects\n+ objects must contain all columns to be inserted into the row\n  + primary keys are mandatory\n\n\u003ca name=\"update\"\u003e\u003c/a\u003e\n\n#### [update](https://github.com/JCThomas4214/CassMask/blob/master/libs/update.ts)(object: [UpdateObject](#updateobject) | Array\\\u003c[UpdateObject](#updateobject)\\\u003e, opts?: [SchemaOptions](#schemaoptions)): Schema\n\n+ first argument can be an object or array of objects\n+ objects must contain two subobjects, 'set' and 'where'\n  + 'set' should contain all the columns you wish to SET (primary keys not allowed)\n  + 'where' should contain the primary key columns to find the row to UPDATE\n\n\u003ca name=\"remove\"\u003e\u003c/a\u003e\n\n#### [remove](https://github.com/JCThomas4214/CassMask/blob/master/libs/remove.ts)(object?: Object | Array\\\u003cObject\\\u003e, opts?: [SchemaOptions](#schemaoptions)): Schema\n\n+ first argument can be empty, an object, or array of objects\n+ objects must contain the primary keys for the WHERE clause to DELETE the row\n\n\u003ca name=\"post\"\u003e\u003c/a\u003e\n\n#### [post](https://github.com/JCThomas4214/CassMask/blob/master/libs/events.ts)(hook: string | Array\\\u003cstring\\\u003e, cb: Function): void;\n\n+ specify one or multiple hooks ('create', 'update', 'remove', or 'find') as the first argument\n+ specify the callback as the function to execute\n  + callback passes two arguments, next(object?), err(message?), and entity: Entity | Array\u003cEntity\u003e\n  + callback must call one of them\n+ sets the cooresponding hook function the Schema/Entity scopes\n\n\u003ca name=\"pre\"\u003e\u003c/a\u003e\n\n#### [pre](https://github.com/JCThomas4214/CassMask/blob/master/libs/events.ts)(hook: string | Array\\\u003cstring\\\u003e, cb: Function): void;\n\n+ specify one or multiple hooks ('create', 'update', 'remove', or 'find') as the first argument\n+ specify the callback as the function to execute\n  + callback passes two arguments, next(object?), err(message?), and entity which are both functions\n  + callback must call one of them\n+ sets the cooresponding hook function the Schema/Entity scopes\n\n\u003ca name=\"methods\"\u003e\u003c/a\u003e\n\n#### [methods](https://github.com/JCThomas4214/CassMask/blob/master/index.ts)(scope: Object): void;\n\n+ scope object containing properties that will be integrated into all instantiated Entity objects\n\n\u003ca name=\"createIndex\"\u003e\u003c/a\u003e\n\n#### [createIndex](https://github.com/JCThomas4214/CassMask/blob/master/index.ts)(indexes: string | Array\\\u003cstring | Array\\\u003cstring\\\u003e\\\u003e): void\n\n+ creates a secondary index for the talbe on table creation\n   + NOTE: to change/add the indexes you will need to drop the table for cassmask to create it again\n\n\u003ca name=\"updateobject\"\u003e\u003c/a\u003e\n\n#### UpdateObject\n\n+ set: Object; object with table attribute key value pairs to update\n+ where: Object; object with PRIMARY KEY key value pairs\n  + ex: { set: {name: 'test'}, where: {id: '123456'}}\n\n\u003ca name=\"schemaoptions\"\u003e\u003c/a\u003e\n\n#### SchemaOptions\n\n+ using?: string; is the CQL update parameter(s) appended in the INSERT, DELETE, UPDATE string\n  + ex: {using: 'TTL 86400'}\n+ if?: string; is the CQL conditions to execute INSERT, DELETE, UPDATE string\n  + ex: {if: 'exists'}\n  + ex: {if: 'played \u003e 10'}\n\n\u003ca name=\"findoptions\"\u003e\u003c/a\u003e\n\n#### FindOptions\n\n+ attributes?: Array\u003cstring | Object\u003e; \"columns to select or exclude from SELECT query\"\n  + ex: {attributes: ['name', 'created', 'id']}\n  + ex: {attributes: {exclude: ['catagory']}}\n+ groupBy?: string; CQL group by string to append to SELECT query\n  + ex: {groupBy: 'created, name'}\n+ orderBy?: string; CQL order by string to append to SELECT query\n  + ex: {orderBy: 'created desc'}\n+ perParitionLimit?: number; limit select per partition\n  + ex: {perPartitionLimit: 3}\n+ limit?: number; limit the SELECT response to certain number of rows\n  + ex: {limit: 1}\n+ allowFiltering?: boolean; append ALLOW FILTERING to query string\n  + ex: {allowFiltering: true}\n  + **It is recommended that this not be used as it causes cluster wide search**\n\n####\n\n\u003ca name=\"entityAPI\"\u003e\u003c/a\u003e\n\n## Entity API\n\n\u003ca name=\"entityconstructor\"\u003e\u003c/a\u003e\n\n#### new [Entity](https://github.com/JCThomas4214/CassMask/blob/master/libs/entity.ts)(item: Object, model: Schema)\n\n+ item should be an object with the key value pairs for a row in a table\n+ state should be the Schema state this Entity belongs to\n  + every Schema will have a state which contains all the important information regarding the model, table, and more\n\n```ts\nimport { Entity } from 'cassmask';\nimport Model from '/path/to/model.ts';\n\nconst object = {\n  col1: [uuid],\n  col2: [timeuuid],\n  col3: [created time],\n  col4: 'awesome',\n  col5: 67\n};\n\nlet entity = new Entity(object, Model);\nentity.save();\n```\n\n\u003ca name=\"entityisempty\"\u003e\u003c/a\u003e\n\n#### [isEmpty](https://github.com/JCThomas4214/CassMask/blob/master/libs/entity.ts)(): boolean\n\n+ will return true if no column attributes are set in the Entity object\n+ else false\n\n\u003ca name=\"entitymerge\"\u003e\u003c/a\u003e\n\n#### [merge](https://github.com/JCThomas4214/CassMask/blob/master/libs/entity.ts)(item: Object): Entity\n\n+ will merge object will the Entity, overriding any matching attributes in the Entity with the object's\n\n\u003ca name=\"entitysave\"\u003e\u003c/a\u003e\n\n#### [save](https://github.com/JCThomas4214/CassMask/blob/master/libs/entity.ts)(): Rx.Observable\u003cany\u003e\n\n+ creates a query string based off this Entity's attributes\n+ will distinguish if the query is an update or insert and execute the appropriate post callback\n+ will NOT execute a pre callback as the object\n+ executes UPDATE query on subscribe\n\n\u003ca name=\"entityremove\"\u003e\u003c/a\u003e\n\n#### [remove](https://github.com/JCThomas4214/CassMask/blob/master/libs/entity.ts)(): Rx.Observable\u003cany\u003e\n\n+ creates a query string based off this Entity's attributes\n+ will NOT execute a pre callback as the object\n+ executes DELETE query on subscribe\n\n\u003ca name=\"TODO\"\u003e\u003c/a\u003e\n\n## TODO\n\n+ Data Type support (Map, Sets, Lists, custom)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcthomas4214%2Fcassmask","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcthomas4214%2Fcassmask","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcthomas4214%2Fcassmask/lists"}