Parse Plugin

Parse plugin provides the bridge necessary to work with Parse JS Client SDK through the intuitive Flew's fetch api.

Install

npm install @flew/core @flew/network @flew/parse

Configure

import { setup } from '@flew/core';
import { parsePlugin } from '@flew/parse';

setup({
  options: {
    driver: 'parse',
    silent: true, // disable internal logs
  },
  plugins: [
    parsePlugin({
      appID: 'MyParseAppId',
      serverURL: 'http://localhost:1337/parse',
      masterKey: 'MyParseAppMasterKey',
    }),
  ],
});
const Parse = require('parse/node');
const { setup } = require('@flew/core');
const { parsePlugin } = require('@flew/parse');

setup({
  options: {
    driver: 'parse',
    silent: true, // disable internal logs
  },
  plugins: [
    parsePlugin(
      {
        appID: 'MyParseAppId',
        serverURL: 'http://localhost:1337/parse',
        masterKey: 'MyParseAppMasterKey',
      },
      Parse,
    ),
  ],
});

Note that when running on Node we need to pass the Parse instance along the plugin to keep its reference internally.

Network call

import { fetch } from '@flew/network';
import { lastValueFrom } from 'rxjs';

// create user
const newUser = await lastValueFrom(
  fetch('User').set({
    name: 'John',
  }),
);

// update user
await lastValueFrom(
  fetch('User').doc(newUser.objectId).update({
    name: 'John Doe',
  }),
);

// get user
fetch('User')
  .where('name', '==', 'John Doe')
  .findOne()
  .subscribe(
    user => console.log(user),
    err => console.log(err),
  );
const { fetch } = require('@flew/network');
const { lastValueFrom } = require('rxjs');

// create user
const newUser = await lastValueFrom(
  fetch('User').set({
    name: 'John',
  }),
);

// update user
await lastValueFrom(
  fetch('User').doc(newUser.objectId).update({
    name: 'John Doe',
  }),
);

// get user
fetch('User')
  .where('name', '==', 'John Doe')
  .findOne()
  .subscribe(
    user => console.log(user),
    err => console.log(err),
  );
Edit this page on GitHub Updated at Sun, Nov 27, 2022