         credential.save (err)->
           return  if failed err, callback, credData
 
-          delegate.addCredential credential, as: "user"
           delegate.addCredential credential, as: "owner", (err)->
             return  if failed err, callback, credential, credData
 

      options ?= { limit : 10 }

      {delegate} = client.connection
      delegate.fetchCredentials as: "user",
        targetOptions : {
          selector, options
        }, callback


  # .share can be used like this:
  #
  # JCredentialInstance.share { user: yes, owner: no, target: "gokmen"}, cb

  share: permit

    advanced: [
      { permission: 'update credential', validateWith: Validators.own }


    success: (client, options, callback)->

      {target, user, owner} = options
      user ?= yes

      setPermissionFor = (target, callback)=>

        Relationship.remove {
          targetId : @getId()
          sourceId : target.getId()
        }, (err)=>

          if user
            as = if owner then 'owner' else 'user'
            target.addCredential this, { as }, (err)-> callback err
          else
            callback err

      JName.fetchModels target, (err, result)=>

