How to use the ember-cloud-firestore-adapter/utils/parser.buildPathFromRef function in ember-cloud-firestore-adapter

To help you get started, we’ve selected a few ember-cloud-firestore-adapter examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mikkopaderes / ember-cloud-firestore-adapter / addon / serializers / cloud-firestore.js View on Github external
extractRelationship(relationshipModelName, relationshipHash) {
    if (isDocumentReference(relationshipHash)) {
      const path = buildPathFromRef(relationshipHash);
      const pathNodes = path.split('/');
      const belongsToId = pathNodes[pathNodes.length - 1];

      return { id: belongsToId, type: relationshipModelName };
    }

    return null;
  },
github mikkopaderes / ember-cloud-firestore-adapter / addon / serializers / cloud-firestore.js View on Github external
modelClass.eachRelationship((name, descriptor) => {
      if (descriptor.kind === 'belongsTo') {
        if (
          Object.prototype.hasOwnProperty.call(resourceHash, name)
          && isDocumentReference(resourceHash[name])
        ) {
          const path = buildPathFromRef(resourceHash[name]);

          links[name] = path;
        }
      } else {
        const cardinality = modelClass.determineRelationshipType(descriptor, this.store);
        let hasManyPath;

        if (cardinality === 'manyToOne') {
          hasManyPath = buildCollectionName(descriptor.type);
        } else {
          const collectionName = buildCollectionName(modelClass.modelName);
          const docId = resourceHash.id;

          hasManyPath = `${collectionName}/${docId}/${name}`;
        }