How to use the feathers-hooks-common.paramsForServer function in feathers-hooks-common

To help you get started, we’ve selected a few feathers-hooks-common 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 Giveth / giveth-dapp / src / components / DelegateMultipleButton.jsx View on Github external
case 'dac':
        options.delegateId = entity.delegateId;
        options.delegateTypeId = entity.id;
        options.status = Donation.WAITING;

        break;
      case 'campaign':
        options.ownerId = entity.projectId;
        options.ownerTypeId = entity.id;
        options.status = Donation.COMMITTED;
        break;
      default:
        break;
    }

    const query = paramsForServer({
      query: {
        amountRemaining: { $ne: 0 },
        ...options,
        $sort: { createdAt: 1 },
        'token.symbol': this.state.selectedToken.symbol,
      },
      schema: 'includeTypeAndGiverDetails',
    });

    // start watching donations, this will re-run when donations change or are added
    this.donationsObserver = feathersClient
      .service('donations')
      .watch({ listStrategy: 'always' })
      .find(query)
      .subscribe(
        donations => {
github Giveth / giveth-dapp / src / components / views / Profile.jsx View on Github external
loadUserDonations() {
    this.donationsObserver = feathersClient
      .service('donations')
      .watch({ listStrategy: 'always' })
      .find(
        paramsForServer({
          schema: 'includeTypeDetails',
          query: {
            giverAddress: this.state.userAddress,
            homeTxHash: { $exists: true },
            // no parentDonations is the 1st of 2 Transfer events emitted when a new donation occurs
            // we want to exclude those
            parentDonations: { $ne: [] },
            canceledPledgeId: null,
            $limit: this.state.itemsPerPage,
            $skip: this.state.skipDonationsPages * this.state.itemsPerPage,
          },
        }),
      )
      .subscribe(
        resp => {
          this.setState({
github Giveth / giveth-dapp / src / components / views / ViewMilestone.jsx View on Github external
id: milestoneId,
            fiatAmount: new BigNumber(resp.data[0].fiatAmount || '0').toFixed(2),
            totalDonated: convertEthHelper(resp.data[0].totalDonated),
            maxAmount: convertEthHelper(resp.data[0].maxAmount),
          }),
        ),
      )
      .catch(err => {
        ErrorPopup('Something went wrong with viewing the milestone. Please try a refresh.', err);
        this.setState({ isLoading: false });
      });

    // lazy load donations
    // TODO: fetch "non committed" donations? add "intendedProjectTypeId: milestoneId" to query to get
    // all "pending approval" donations for this milestone
    const query = paramsForServer({
      query: {
        ownerTypeId: milestoneId,
        amountRemaining: { $ne: 0 },
        status: { $ne: Donation.FAILED },
      },
      schema: 'includeGiverDetails',
      $sort: { createdAt: -1 },
    });

    this.donationsObserver = feathersClient
      .service('donations')
      .watch({ listStrategy: 'always' })
      .find(query)
      .subscribe(
        resp =>
          this.setState({
github Giveth / giveth-dapp / src / contextProviders / DelegationProvider.jsx View on Github external
getAndWatchDonations() {
    // here we get all the ids.
    // TODO: less overhead here if we move it all to a single service.
    // NOTE: This will not rerun, meaning after any dac/campaign/milestone is added

    const dacsIds = this.state.dacs
      .filter(c => c.ownerAddress === this.props.currentUser.address)
      .map(c => c._id);

    const campaignIds = this.state.campaigns
      .filter(c => c.ownerAddress === this.props.currentUser.address)
      .map(c => c._id);

    const query = paramsForServer({
      query: {
        amountRemaining: { $ne: 0 },
        $or: [
          { ownerTypeId: { $in: campaignIds }, status: Donation.COMMITTED },
          {
            delegateTypeId: { $in: dacsIds },
            status: { $in: [Donation.WAITING, Donation.TO_APPROVE] },
          },
          {
            ownerTypeId: this.props.currentUser.address,
            delegateId: { $exists: false },
            status: Donation.WAITING,
          },
          // {
          // ownerTypeId: this.props.currentUser.address,
          // delegateTypeId: { $gt: 0 },
github Giveth / giveth-dapp / src / services / DACService.js View on Github external
static subscribeDonations(id, onSuccess, onError) {
    return feathersClient
      .service('donations')
      .watch({ listStrategy: 'always' })
      .find(
        paramsForServer({
          query: {
            status: { $ne: Donation.FAILED },
            delegateTypeId: id,
            isReturn: false,
            intendedProjectId: { $exists: false },
            $sort: { createdAt: -1 },
          },
          schema: 'includeTypeAndGiverDetails',
        }),
      )
      .subscribe(resp => {
        onSuccess(resp.data.map(d => new Donation(d)));
      }, onError);
  }
github Giveth / giveth-dapp / src / contextProviders / DonationProvider.jsx View on Github external
loadDonations() {
    if (this.props.currentUser === undefined) return;
    this.donationsObserver = feathersClient
      .service('donations')
      .watch({ listStrategy: 'always' })
      .find(
        paramsForServer({
          schema: 'includeTypeDetails',
          query: {
            giverAddress: this.props.currentUser.address,
            amountRemaining: { $ne: 0 },
            $limit: this.state.itemsPerPage,
            $skip: this.state.skipPages * this.state.itemsPerPage,
            $sort: { createdAt: -1 },
          },
        }),
      )
      .subscribe(
        resp => {
          this.setState(prevState => ({
            donations: resp.data.map(d => new Donation(d)),
            skipPages: resp.skip / prevState.itemsPerPage,
            totalResults: resp.total,
github Giveth / giveth-dapp / src / services / CampaignService.js View on Github external
static getDonations(id, $limit = 100, $skip = 0, onSuccess = () => {}, onError = () => {}) {
    return feathersClient
      .service('donations')
      .find(
        paramsForServer({
          query: {
            status: { $ne: Donation.FAILED },
            $or: [{ intendedProjectTypeId: id }, { ownerTypeId: id }],
            ownerTypeId: id,
            isReturn: false,
            $sort: { createdAt: -1 },
            $limit,
            $skip,
          },
          schema: 'includeTypeAndGiverDetails',
        }),
      )
      .then(resp => onSuccess(resp.data.map(d => new Donation(d)), resp.total))
      .catch(onError);
  }
github Giveth / giveth-dapp / src / services / MilestoneService.js View on Github external
static getDonations(id, $limit = 100, $skip = 0, onSuccess = () => {}, onError = () => {}) {
    return feathersClient
      .service('donations')
      .find(
        paramsForServer({
          query: {
            $or: [
              {
                amountRemaining: { $ne: 0 },
                status: { $ne: Donation.FAILED },
                $or: [{ intendedProjectTypeId: id }, { ownerTypeId: id }],
              },
              {
                status: Donation.PAID,
                $or: [{ intendedProjectTypeId: id }, { ownerTypeId: id }],
              },
            ],
            $sort: { usdValue: -1, createdAt: -1 },
            $limit,
            $skip,
          },