Link users and Dwolla customers

Please be sure of your agent type and version and pick the right documentation accordingly.

This is the documentation of the forest-express-sequelize and forest-express-mongoose Node.js agents that will soon reach end-of-support.

forest-express-sequelize v9 and forest-express-mongoose v9 are replaced by @forestadmin/agent v1.

Please check your agent type and version and read on or switch to the right documentation.

The implementation of this smart relationship (belongsTo) relies on a Dwolla service that will retrieve the Dwolla customer based on the user's email. The Dwolla service is described in another section.

// forest/users.js
const { collection } = require('forest-express-sequelize');

const DwollaService = require('../services/dwolla-service');
let dwollaService = new DwollaService(
  process.env.DWOLLA_APP_KEY,
  process.env.DWOLLA_APP_SECRET,
  process.env.DWOLLA_ENVIRONMENT
);

collection('users', {
  actions: [],
  fields: [
    {
      field: 'dwollaCustomer',
      type: 'String',
      reference: 'dwollaCustomers.id',
      get: function (user) {
        return dwollaService.getCustomerSmartRelationship(user);
      },
    },
  ],
  segments: [],
});

Last updated