Look up the name of the primary key field
for the collection with the specified identity.

@param  {String}   collectionIdentity
@return {String}
493965
function (collectionIdentity) {
      if (!collectionIdentity) return;
      var schema = connectionObject.collections[collectionIdentity].attributes;
      
      if(!schema)
       return 'id'; 
      
      var key;
      for(key in schema){
        if(schema[key].primaryKey)
          return key;
      }
      return 'id';
    }
765020
function( collectionID, key ) {
            collectionID = collectionID.toLowerCase();

            var deferred = q.defer();
            schemaSyncer.prepCollection(collectionID)
            .then( function() {
                sqliteObj.find( collectionID, {'_id': key}, false, 1 ).then(
                    // success
                    function(r) {
                        if ( r && r.length > 0 ) {
                            var firstElement = r[0];
                            if ( isValue(firstElement[key]) ) {
                                var value = firstElement[key];
                                deferred.resolve(value);
                            } else {
                                deferred.resolve(firstElement);
                            }
                        }
                        return deferred.resolve(null);
                    },

                    // failure
                    function(e) {
                        return q.reject(e);
                    }
                );
            });

            return deferred.promise;
        }
20521
function getId(id){
        if(_.isObject(id) && !_.isUndefined(id.id)){
            if (objectIdRegex.test(id.id)) {
                id = id.id;
            }
            else {
                id = null;
            }
        }
        return id;
    }
109458
function findIdentityMatch()
    {
        $identity = $this->wrap->findIdentityMatch();
        if (!$identity)
            return false;
        
        $return   = $this->identity_map->clean();
        $return->import($identity);
        return $identity;
    }
18088
def find_id_metadata(collection_name)
    collection_data = @collections.fetch(collection_name)
    class_metadata = @class_metadata.fetch(collection_data[:type].to_s)
    key = class_metadata.select{|k,h| h.is_key }.collect{|k,h| h.name }[0]
    class_metadata[key]
  end
231480
public Object lookup(Identity oid)
    {
        Object result = null;
        // 1. lookup an instance in session cache
        CacheEntry entry = (CacheEntry) sessionCache.get(oid);
        if(entry != null)
        {
            result = entry.get();
        }
        if(result == null)
        {
            result = lookupFromApplicationCache(oid);
            // 4. if we have a match
            // put object in session cache
            if(result != null)
            {
                doInternalCache(oid, result, TYPE_CACHED_READ);
                materializeFullObject(result);
                if(log.isDebugEnabled()) log.debug("Materialized object from second level cache: " + oid);
            }
        }
        if(result != null && log.isDebugEnabled())
        {
            log.debug("Match for: " + oid);
        }
        return result;
    }
749155
private static String getIdentityDocument(final HttpClient client) throws IOException {
    try {
      final HttpGet getInstance = new HttpGet();
      getInstance.setURI(INSTANCE_IDENTITY_URI);
      final HttpResponse response = client.execute(getInstance);
      if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
        throw new IOException("failed to get instance identity, tried: " + INSTANCE_IDENTITY_URL + ", response: " + response.getStatusLine().getReasonPhrase());
      }
      return EntityUtils.toString(response.getEntity());
    } catch (Exception e) {
      throw new IOException("failed to get instance identity", e);
    }
  }
1197984
function cacheKey (id) {
    //  get cache id
    var cacheId = stableId({
        columnsId: this.cache.model.columnsId,
        modelViewInstanceIds: this.modelViewInstanceIds,
        recordId: id,
    })
    // create cache key
    return `${this.cache.model.name}:view:id:record:${cacheId}`
}
145126
function createIdentifierNode(name) {
  return (scope, opts) => {
    const property = get(opts.properties, name);

    return property ? property(scope) : get(scope, name);
  };
}
803201
function (identifier) {
            var self = this;

            // Search for Lookup records associated with the identifier (id, macAddress, ipAddress).
            return waterline.lookups.findByTerm(identifier).then(function (documents) {
                // Identify a record with a node id.
                var lookup = _.find(documents, function (item) {
                    return item.node !== undefined;
                });
                // If we find a record with a node id then we can lookup the node with it,
                // otherwise we can try to lookup with the identifier directly.
                if (lookup) {
                    return self.findOne({ id: lookup.node });
                } else {
                    return self.findOne({ id: identifier })
                    .then(function(rec) {
                        if(!rec) {
                            return self.findOne({identifiers: identifier});
                        }
                        return rec;
                    });
                }
            });
        }
530419
private Identity getReferencedObjectIdentity(Object obj, ObjectReferenceDescriptor rds, ClassDescriptor cld)
    {
        Object[] fkValues = rds.getForeignKeyValues(obj, cld);
        FieldDescriptor[] fkFieldDescriptors = rds.getForeignKeyFieldDescriptors(cld);
        boolean hasNullifiedFKValue = hasNullifiedFK(fkFieldDescriptors, fkValues);
        /*
        BRJ: if all fk values are null there's no referenced object

        arminw: Supposed the given object has nullified FK values but the referenced
        object still exists. This could happend after serialization of the main object. In
        this case all anonymous field (AK) information is lost, because AnonymousPersistentField class
        use the object identity to cache the AK values. But we can build Identity anyway from the reference
        */
        if (hasNullifiedFKValue)
        {
            if(BrokerHelper.hasAnonymousKeyReference(cld, rds))
            {
                Object referencedObject = rds.getPersistentField().get(obj);
                if(referencedObject != null)
                {
                    return pb.serviceIdentity().buildIdentity(referencedObject);
                }
            }
        }
        else
        {
            // ensure that top-level extents are used for Identities
            return pb.serviceIdentity().buildIdentity(rds.getItemClass(), pb.getTopLevelClass(rds.getItemClass()), fkValues);
        }
        return null;
    }
199280
@Beta
    public MSICredentials withIdentityId(String identityId) {
        this.identityId = identityId;
        this.clientId = null;
        this.objectId = null;
        return this;
    }
99389
def read_identities_by_scope(self, scope_id, query_membership=None, properties=None):
        
        query_parameters = {}
        if scope_id is not None:
            query_parameters['scopeId'] = self._serialize.query('scope_id', scope_id, 'str')
        if query_membership is not None:
            query_parameters['queryMembership'] = self._serialize.query('query_membership', query_membership, 'str')
        if properties is not None:
            query_parameters['properties'] = self._serialize.query('properties', properties, 'str')
        response = self._send(http_method='GET',
                              location_id='28010c54-d0c0-4c89-a5b0-1c9e188b9fb7',
                              version='5.0',
                              query_parameters=query_parameters)
        return self._deserialize('[Identity]', self._unwrap_collection(response))
22728
public static Map<Identity, JsonNode> getDocumentIdMap(List<JsonNode> list, List<String> identityFields) {
        Map<Identity, JsonNode> map = new HashMap<>();
        if (list != null) {
            LOGGER.debug("Getting doc IDs for {} docs, fields={}", list.size(), identityFields);
            for (JsonNode node : list) {
                Identity id = new Identity(node, identityFields);
                LOGGER.debug("ID={}", id);
                map.put(id, node);
            }
        }
        return map;
    }
608975
function _addEntityIdentifier(entity, obj) {
    if (entity.constructor === EVT.Entity.Product) {
      obj.product = entity.id;
    } else if (entity.constructor === EVT.Entity.Thng) {
      obj.thng = entity.id;
    } else if (entity.constructor === EVT.Entity.Collection) {
      obj.collection = entity.id;
    }

    return obj;
  }
1050435
def _get_pk_from_identity(obj):
        """"""
        from sqlalchemy.orm.util import identity_key

        cls, key = identity_key(instance=obj)[0:2]
        return ":".join(text_type(x) for x in key)
1045075
final protected function retrieveObjectIdentityPrimaryKey(ObjectIdentityInterface $oid)
    {
        return $this->connection->executeQuery($this->getSelectObjectIdentityIdSql($oid))->fetchColumn();
    }