<commit_before>Geddy uses the [Model](http://github.com/mde/model) for it's model layer. It's an abstract ORM that is compatible with many different types of databases, from Postgres to in memory, and MongoDB ro Riak.

* * *

#### definition
Model uses a pretty simple syntax for defining a model. (It should look familiar to anyone who has used an ORM like ActiveRecord, DataMapper, Django's models, or SQLAlchemy.)

* * *

#### .defineProperties
`defineProperties( properties )`

defines the properties for your model.

##### properties
- `properties [object]`: an object keyed by name of properties to define

##### example
```
var User = function () {
  this.defineProperties({
    login: {type: 'string', required: true}
  , password: {type: 'string', required: true}
  , lastName: {type: 'string'}
  , firstName: {type: 'string'}
  });
}
```

* * *

#### .property
`property( name, type, options )`

defines a single property

##### name
- `name [string]`: the name of the property

##### type
- `type [string]`: the type of the property
	- `’string’`
	- `’text’`
	- `’number’`
	- `’int’`
	- `’boolean’`
	- `’object’`
	- `’array’`
	- `’datetime’`
	- `’date’`
	- `’time’`

##### options
- `required [boolean]`: sets the property to be required

##### examples
```
this.property('login', 'string', {required: true});
this.property('password', 'string', {required: true});
this.property(‘joined’, ‘datetime);
this.property(‘premium’, ’boolean);
```

* * *

#### .validatesPresent
`validatesPresent( property )`

Sets up a validation to make sure that the property is present.

##### property
- `property [string]`: the name of the property to validate

##### example
```
this.validatesPresent('login');
// makes sure that the login property is present
```

* * *

#### .validatesFormat
`validatesFormat( property, regex, options )`

Sets up a validation to make sure that the property is formatted correctly.

##### property
- `property [string]`: the name of the property to validate

##### regex
- `regex [string]`: a regular expression that the property value must pass

##### options
- `message [string]`: a message to give the use if the validation fails

##### example
```
this.validatesFormat('login', /[a-z]+/, {message: ‘cannot contain numbers’});
// makes sure that the login property does not contain numbers
```

* * *

#### .validatesLength
`validatesLength( property, options )`

Sets up a validation to make sure that the property meets certain lenght requirements.

##### property
- `property [string]`: the name of the property to validate

##### options
- `min [number]`: the minimum length of the property
- `max [number]`: the maximum length of the property

##### example
```
this.validatesLength(‘login', {min: ‘3’});
// makes sure that the login property is at least 3 characters long


this.validatesLength(‘login', {min: ‘20’});
// makes sure that the login property is not longer than 20 characters
```

* * *

#### .validatesConfirmed
`validatesConfirmed( property, param )`

Sets up a validation to make sure that the property has been confirmed.

##### property
- `property [string]`: the name of the property to validate

##### param
- `param [string]`: the param required to match

##### example
```
this.validatesConfirmed('password', '<PASSWORD>Password');
// confirms that password and confirmPassword are equal
```

* * *

#### .validatesWithFunction
`validatesWithFunction( property, fn )`

Sets up a validation to make sure that the property has been confirmed.

##### property
- `property [string]`: the name of the property to validate

##### fn
- `fn [function]`: a function which, when passed the value of the property, will return true or false

##### example
```
this.validatesWithFunction('password', function (val) {
      // Something that returns true or false
      return val.length > 0;
});
// uses the function to see if th length of password is greater than 0
```

* * *

#### .hasOne
`hasOne( model )`

Sets up a has one relationship between this model and another.

##### model
- `property [string]`: the name of the model that this model has one of.

##### example
```
this.hasOne('Profile');
// sets up a has one relationship
// user -> has one -> profile
```

* * *

#### .hasMany
`hasMany( model )`

Sets up a has many relationship between this model and another.

##### model
- `property [string]`: the pluralized name of the model that this model has many of.

##### example
```
this.hasMany(‘Friends’);
// sets up a has many relationship
// user -> has many -> friends
```

* * *

#### .adapter
`this.adapter`

Defines the database adapter for this model

##### examples
```
this.adapter = ‘mongo’;
// makes this model use mongo for it’s database


this.adapter = ‘riak’


this.adapter = ‘postgres’


this.adapter = ‘memory’
```

* * *<commit_msg>most of the model docs are done, just need to do the query stuff<commit_after>Geddy uses the [Model](http://github.com/mde/model) module for it's model layer. It's an abstract ORM that is compatible with many different types of databases, from Postgres to in memory, and MongoDB ro Riak.

* * *

#### definition
Model uses a pretty simple syntax for defining a model. (It should look familiar to anyone who has used an ORM like ActiveRecord, DataMapper, Django's models, or SQLAlchemy.)

* * *

#### .defineProperties
`defineProperties( properties )`

defines the properties for your model.

##### properties
- `properties [object]`: an object keyed by name of properties to define

##### example
```
var User = function () {
  this.defineProperties({
    login: {type: 'string', required: true}
  , password: {type: 'string', required: true}
  , lastName: {type: 'string'}
  , firstName: {type: 'string'}
  });
}
```

* * *

#### .property
`property( name, type, options )`

defines a single property

##### name
- `name [string]`: the name of the property

##### type
- `type [string]`: the type of the property
	- `’string’`
	- `’text’`
	- `’number’`
	- `’int’`
	- `’boolean’`
	- `’object’`
	- `’array’`
	- `’datetime’`
	- `’date’`
	- `’time’`

##### options
- `required [boolean]`: sets the property to be required

##### examples
```
this.property('login', 'string', {required: true});
this.property('password', 'string', {required: true});
this.property(‘joined’, ‘datetime);
this.property(‘premium’, ’boolean);
```

* * *

#### .validatesPresent
`validatesPresent( property )`

Sets up a validation to make sure that the property is present.

##### property
- `property [string]`: the name of the property to validate

##### example
```
this.validatesPresent('login');
// makes sure that the login property is present
```

* * *

#### .validatesFormat
`validatesFormat( property, regex, options )`

Sets up a validation to make sure that the property is formatted correctly.

##### property
- `property [string]`: the name of the property to validate

##### regex
- `regex [regex]`: a regular expression that the property value must pass

##### options
- `message [string]`: a message to give the use if the validation fails

##### example
```
this.validatesFormat('login', /[a-z]+/, {message: ‘cannot contain numbers’});
// makes sure that the login property does not contain numbers
```

* * *

#### .validatesLength
`validatesLength( property, options )`

Sets up a validation to make sure that the property meets certain lenght requirements.

##### property
- `property [string]`: the name of the property to validate

##### options
- `min [number]`: the minimum length of the property
- `max [number]`: the maximum length of the property

##### example
```
this.validatesLength(‘login', {min: ‘3’});
// makes sure that the login property is at least 3 characters long


this.validatesLength(‘login', {min: ‘20’});
// makes sure that the login property is not longer than 20 characters
```

* * *

#### .validatesConfirmed
`validatesConfirmed( property, param )`

Sets up a validation to make sure that the property has been confirmed.

##### property
- `property [string]`: the name of the property to validate

##### param
- `param [string]`: the param required to match

##### example
```
this.validatesConfirmed('password', '<PASSWORD>Password');
// confirms that password and confirmPassword are equal
```

* * *

#### .validatesWithFunction
`validatesWithFunction( property, fn )`

Sets up a validation to make sure that the property has been confirmed.

##### property
- `property [string]`: the name of the property to validate

##### fn
- `fn [function]`: a function which, when passed the value of the property, will return true or false

##### example
```
this.validatesWithFunction('password', function (val) {
      // Something that returns true or false
      return val.length > 0;
});
// uses the function to see if th length of password is greater than 0
```

* * *

#### .hasOne
`hasOne( model )`

Sets up a has one relationship between this model and another.

##### model
- `model [string]`: the name of the model that this model has one of.

##### example
```
this.hasOne('Profile');
// sets up a has one relationship
// user -> has one -> profile
```

* * *

#### .hasMany
`hasMany( model )`

Sets up a has many relationship between this model and another.

##### model
- `model [string]`: the pluralized name of the model that this model has many of.

##### example
```
this.hasMany(‘Friends’);
// sets up a has many relationship
// user -> has many -> friends
```

* * *

#### .adapter
`this.adapter`

Defines the database adapter for this model

##### examples
```
this.adapter = ‘mongo’;
// makes this model use mongo for it’s database


this.adapter = ‘riak’


this.adapter = ‘postgres’


this.adapter = ‘memory’
```

* * *
{'fraction_non_alphanumeric': 0.15248630207794894, 'fraction_numerical': 0.0016540887005065646, 'mean_word_length': 4.153969099627065, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2831622', 'n_tokens_mistral': 2975, 'n_tokens_neox': 2799, 'n_words': 1142}