GithubHelp home page GithubHelp logo

geosander / fme-mongodbobjectidgenerator Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 41 KB

Custom transformer for FME® that generates a MongoDB (BSON) Object ID or validates an existing one

License: GNU General Public License v3.0

fme transformer custom-transformer mongodb bson

fme-mongodbobjectidgenerator's Introduction

FME® MongoDBObjectIDGenerator

About

Generates new MongoDB Document ID's (also known as BSON ObjectID's) or validates existing ones.
A BSON ObjectID is a 12 byte binary string that is built up as follows:

  • a 4-byte value representing the seconds since the Unix epoch,
  • a 3-byte machine identifier,
  • a 2-byte process id, and
  • a 3-byte counter, starting with a random value.

However, this transformer will validate/generate its 24 character hexadecimal string equivalent.

Why use this transformer?
Although FME's MongoDB writer will generate MongoDB ID's automatically, there might be a case where you want to create documents that reference other documents by ObjectID. Therefore, you would need to generate an ID in advance, that will be written to the mongodb_id attribute. Note that you should rename this attribute (to anything you like) on the document feature if it uses this ObjectID as a foreign key (i.e. the "child"). Otherwise, the writer uses the ObjectID on both the "parent" and the "child" document as a primary key, which will fail.

Notes

  • Also available on FME Hub for convenient installation.
  • This transformer uses the Node.js abilities of the JavaScriptCaller, which currently is a beta feature of FME.
  • There are no dependencies, because the code to generate the ObjectID's has been embedded. The original code can be found here.
  • Released under GNU General Public License v3.0.
  • If you notice a bug or desire a new feature, please contact me. Or make a pull request!
  • This FME workspace is used for testing and provides some examples.

Usage

Operation Mode
When set to Generate, the transformer will create new MongoDB ObjectID's and store them in the mongodb_id attribute. If the attribute exists, it will be overwritten (!).
When set to Validate, the transformer assumes that the mongodb_id attribute exists and tries to validate it (see Overview). No ObjectID's will be created or overwritten in this mode. If a feature has an invalid ObjectID, it will be output through the Rejected port. The failure reason will be stored in the attribute mongodb_id_error.

fme-mongodbobjectidgenerator's People

Contributors

geosander avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.