 
     # returns a collection for the given association.
     collectionFor: (name) ->
-        klass = @getClassFor(name)
-        if klass::isModel
-            klass.Collection
+        @collections[name] ||= (
+            klass = @getClassFor(name)
+            klass = klass.Collection if true == klass::isModel
+            new klass
+        )
+
+    # set from collection
+    getModelFromCollection: (model, name, collection) ->
+        throw("#{name} isn't an association") unless _.has(@definitions, name)
+        if not model[name].isNew()
+            return model[name]
         else
-            klass
-
+            id = model[@pk(name)]
+            model = collection.get(id)
+            collection.fetchId(id) if id and not model
+            model
 
     # will be called in the scope of the parent model
     createCollection: (association, name, definition, fk, pk, target_class) ->

    set: (model, data) ->
        this._set(model, data, 'set')
        for name, value of data
            if @definitions[name] && value?.isModel && !value.isNew()
                model[@pk(name)] = if value then value.getId() else null

    setFromServer: (model, data) ->

# ------------------------------------------------------------------ #
# Handles Association definitions.                                   #
# It creates a derived definition for each one                       #
# Note!  An AssociationMap is created for each type of Model, and    #
# is shared between all instances                                    #
# ------------------------------------------------------------------ #
class Lanes.Models.AssocationMap
    constructor: (@klass) ->
