<commit_before># Cassandrom

Cassandrom is a Cassandra object modeling tool for Node JS.


# Installation

Install [node.js](http://nodejs.org/) and [cassandra](http://cassandra.apache.org/download/)

```sh
$ npm install cassandrom
```


# Connecting to Cassandra
To use cassandrom first create connection.

```js
var cassandrom = require('cassandrom');

cassandrom.createConnection({ contactPoints: [
  'localhost'
  // , 'another-host',
  ], keyspace: 'keyspace'});

```

# Defining a Schema

```js
var schema = new cassandrom.Schema({
  userId:   { type: cassandrom.UUIDType, required: true, trim: true, default: cassandrom.uuid },
  fullName: { type: String, required: true, trim: true },
  username: { type: String, required: true, unique: true, trim: true },
  email:    { type: String, required: true, unique: true, trim: true },
  password: { type: String, required: true },
  date:     { type: Date, default: Date.now, required: true }

}, true);
```

# Get Model and Start work

```js
var User = cassandrom.model("User", schema);
```

# Create and save Model

```js
User.create({
  fullName: '<NAME>',
  username: 'john',
  email: '<EMAIL>',
  password: '<PASSWORD>'
}, function (error, user) {
  if(error) {
    console.log('Error during user save: ' + error);
  } else {
    console.log('User saved ' + user.userId + ' date ' + user.date);
  }
});
```

# Searching
Find all records match the certain field.
```js
User.find({ username: name }, function(error, results) {
  console.log('Find ' + results.length + ' users');
});
```

Find only one record.
```js
User.findOne({ username: name }, function(error, user) {
  console.log('Find found ' + user);
});
```

# Add New Methods

```js
schema.statics.findByUserame = function(name, callback) {
  this.findOne({ username: name }, callback);
};

schema.statics.findById = function(id, callback) {
  this.findOne({ userId: id }, callback);
};
```

# Cassandra Driver access
DataStax [nodejs-driver](https://github.com/datastax/nodejs-driver) for Apache Cassandra were used.<commit_msg>add licence<commit_after># Cassandrom

Cassandrom is a Cassandra object modeling tool for Node JS.


# Installation

Install [node.js](http://nodejs.org/) and [cassandra](http://cassandra.apache.org/download/)

```sh
$ npm install cassandrom
```


# Connecting to Cassandra
To use cassandrom first create connection.

```js
var cassandrom = require('cassandrom');

cassandrom.createConnection({ contactPoints: [
  'localhost'
  // , 'another-host',
  ], keyspace: 'keyspace'});

```

# Defining a Schema

```js
var schema = new cassandrom.Schema({
  userId:   { type: cassandrom.UUIDType, required: true, trim: true, default: cassandrom.uuid },
  fullName: { type: String, required: true, trim: true },
  username: { type: String, required: true, unique: true, trim: true },
  email:    { type: String, required: true, unique: true, trim: true },
  password: { type: String, required: true },
  date:     { type: Date, default: Date.now, required: true }

}, true);
```

# Get Model and Start work

```js
var User = cassandrom.model("User", schema);
```

# Create and save Model

```js
User.create({
  fullName: '<NAME>',
  username: 'john',
  email: '<EMAIL>',
  password: '<PASSWORD>'
}, function (error, user) {
  if(error) {
    console.log('Error during user save: ' + error);
  } else {
    console.log('User saved ' + user.userId + ' date ' + user.date);
  }
});
```

# Searching
Find all records match the certain field.
```js
User.find({ username: name }, function(error, results) {
  console.log('Find ' + results.length + ' users');
});
```

Find only one record.
```js
User.findOne({ username: name }, function(error, user) {
  console.log('Find found ' + user);
});
```

# Add New Methods

```js
schema.statics.findByUserame = function(name, callback) {
  this.findOne({ username: name }, callback);
};

schema.statics.findById = function(id, callback) {
  this.findOne({ userId: id }, callback);
};
```

# Cassandra Driver access
DataStax [nodejs-driver](https://github.com/datastax/nodejs-driver) for Apache Cassandra were used.

# Creators

_<NAME>_ - https://twitter.com/kiril

# Copyright and license
Code and documentation copyright 2015 [Lookify.co](http://www.lookify.co) Code released under the Apache 2.0 license.
{'fraction_non_alphanumeric': 0.16444755898154637, 'fraction_numerical': 0.001401541695865452, 'mean_word_length': 4.215590742996346, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 3, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1705393', 'n_tokens_mistral': 1449, 'n_tokens_neox': 1395, 'n_words': 403}