Tidy up model building from data sources

See https://github.com/strongloop/loopback/issues/560
Test improvement, shows _targetClass camelCase bug

There is an issue where setting _targetClass on hasAndBelongsToMany
relations with a camel-case model name, fails.

Signed-off-by: Khashayar Hajian <me@khashayar.me>
Fix camel-case issue where relation is 'hasAndBelongsToMany' #304

Signed-off-by: Khashayar Hajian <me@khashayar.me>
Merge pull request #303 from khashayar/feature/test-improvement

Test improvement, shows _targetClass camelCase bug
Merge pull request #301 from strongloop/feature/allow-base-for-discovery

Tidy up model building from data sources
Add contribution guidelines

Uses https://cla.strongloop.com
Extract mergeQuery and setScopeValuesFromWhere

Related to #274 - in preparation of default scope
Fix conflict
Implemented collection setting for Memory connector
Properly reset Memory connector cache on automigrate
Fix conflict
Fix conflict
Full test CRUD suite for default scope
Allow default scope to be a function
Test default scope with relations
applyProperties => properties (object/false)
Cleanup, consistency: allow properties to be a function

Also, pass along the current instance, for any instance method as a
context (save, updateAttributes).
Allow `attributes` as an alias for `properties` (for LDL)