Skip to main content

Create a Firestore Writer application

You can create an application that writes to Firestore using Flow Designer or TQL. Before you begin, complete the steps in Initial setup for Firestore Writer, including creating the Firestore connection profile, and create the target collections in Firestore: Firestore Writer does not create collections automatically.

The following TQL example replicates ongoing changes from MongoDB to Firestore, with a checkpoint collection specified for exactly-once processing:

CREATE APPLICATION MongoToFirestore RECOVERY 5 SECOND INTERVAL;

CREATE SOURCE MongoSrc USING Global.MongoDBReader (
  connectionUrl: 'mongodb+srv://testcluster.sb9fh.mongodb.net',
  authDB: 'admin',
  authType: 'Default',
  userName: 'admin',
  password: '******',
  mode: 'Incremental',
  collections: 'src.load',
  FetchSize: 1000,
  readPreference: 'primaryPreferred',
  connectionRetryPolicy: 'retryInterval=30,maxRetries=3'
)
OUTPUT TO o1;

CREATE TARGET FirestoreTrg USING Global.FirestoreWriter (
  connectionProfileName: 'admin.FirestoreCP',
  collections: 'src.load,striim-firestore-db.load',
  CheckpointCollection: 'striim-firestore-db.chkpoint',
  batchpolicy: 'EventCount:10, Interval:30',
  ConnectionRetryPolicy: 'retryInterval=60, maxRetries=3',
  OrderedWrites: true,
  upsertMode: false,
  keyseparator: ':'
)
INPUT FROM o1;

END APPLICATION MongoToFirestore;

The following example performs an initial load from Oracle to Firestore using Database Reader:

CREATE APPLICATION OracleToFirestore;

CREATE SOURCE DBSrc USING Global.DatabaseReader (
  ConnectionURL: 'jdbc:oracle:thin:@localhost:1521:ORCL',
  Username: 'qatest',
  Password: '******',
  Tables: 'QATEST.AUTOTERM1',
  DatabaseProviderType: 'Default',
  FetchSize: 100,
  CreateSchema: false,
  QuiesceOnILCompletion: false
)
OUTPUT TO o1;

CREATE TARGET FirestoreTrg USING Global.FirestoreWriter (
  connectionProfileName: 'admin.FirestoreCP',
  collections: 'QATEST.AUTOTERM1,striim-firestore-db.oracle',
  batchpolicy: 'EventCount:1000, Interval:30',
  ConnectionRetryPolicy: 'retryInterval=60, maxRetries=3',
  OrderedWrites: false,
  upsertMode: false,
  keyseparator: ':'
)
INPUT FROM o1;

END APPLICATION OracleToFirestore;

For details of all adapter properties, see Programmer's reference for Firestore Writer.