Coder Social home page Coder Social logo

Comments (8)

nstott avatar nstott commented on September 14, 2024

If we agree that merging the joined data into the existing document should be handled in a javascript vm in the source, then we're presented with a bit of a dilemma about how to request lookups
i.e. consider the case of redis, and mongo,
with redis we might want to query with
GET <key> or HGET <key> <value>
whereas with mongo, we'd want to do a db.findOne({_id: <id>}), or possibly a findOne(<bson query>)

We are forced to either provide a generic function that can take a variety of ways to query,
ie
Mongo

module.exports = function(doc, source) {
    doc["author"] = source.lookup({namespace: "boom.authors", query: {_id: doc.author_id}});
}

Redis

module.exports = function(doc, source) {
    doc["author"] = source.lookup({method: "HGET", key: "authors", value: doc.author_id});
}

or we provide specialized functions for each source type.
Redis

module.exports = function(doc, source) {
    doc["author"] = source.HGET("authors", doc.author_id);
}

Each of these options has drawbacks.

opinions?

from transporter.

mrkurt avatar mrkurt commented on September 14, 2024

I think you can probably get a long way with a stupid simple lookup interface right now, even just k/v lookups (find by _id in Mongo, get in Redis. Advanced queries (anything special on Redis probably counts) can come later.

And, the less actual work that happens in Javascript the more chance there is to optimize / scale this stuff later. Letting people do arbitrary queries and then run logic against them in JS seems like it's going to create a really hard-to-optimize performance bottleneck.

from transporter.

andrewreedy avatar andrewreedy commented on September 14, 2024

πŸ‘

from transporter.

tiengtinh avatar tiengtinh commented on September 14, 2024

πŸ‘ This is also one feature that I'm looking forward to

from transporter.

shividhar avatar shividhar commented on September 14, 2024

+1 Definitely a sought after feature.

from transporter.

allanlundhansen avatar allanlundhansen commented on September 14, 2024

+1 denormalization of data for elasticsearch should be possible

from transporter.

vinodtolexo avatar vinodtolexo commented on September 14, 2024

+1 from me as well I can also contribute tothe code if required .

from transporter.

jipperinbham avatar jipperinbham commented on September 14, 2024

dumping what the plan is here so I don't forget when I get to this soon...

t.Source(mongodb({uri: "connection string"…}).
  Join(postgres({uri: "connection string"…}), {
    id_map: {"account_id": "id"}, 
    field_map: {
      "name": "flegergle", 
      "slug": "account_slug"
   },
    query_ref: "accounts"}).
  Save(elasticsearch({uri: "connection string"...})
)

NOTE this is contingent on changes to the javascript DSL which is currently in progress.

the general idea here is to have a new method Join(...) that takes two parameters, an adaptor and a configuration for performing the query.

in the above pipeline, the following scenario would take place:

original doc

{
  "_id": "somespecial_ID",
  "name": "fancypants",
  "type": "foo",
  "account_id": 1567
}

and when sent to the Join the following query would be executed:

SELECT name AS flegergle, slug AS account_slug FROM accounts WHERE id = 1567

which would then send the following document down the pipeline:

{
  "_id": "somespecial_ID",
  "name": "fancypants",
  "type": "foo",
  "account_id": 1567,
  "flegergle": "Super Duper",
  "account_slug": "super-duper"
}

The initial implementation of this will likely only support joins to a single table/collection.

from transporter.

Related Issues (20)

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.