lenra-io / lenra-io/query-parser

[Task] Update the Query Parser to be able to parse to AST and plain JSON with ObjectId

Open
#19 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Elixir
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Currently the ObjectID is encoded as a simple string (hexadecimal) and decoded as a string too.
This force us to navigate through the entire json object and try to parse every string into a ObjectId.

We want to change this for performance reason to encode the ObjectId as a specific string "ObjectId(xxxx)" and decode as a BSON.ObjectId (with elixir-bson

What should be done

The parser should be able to parse a String into a JSON object or an AST tree that represent the query.
Currently, the parser only parse into AST.
In both case, the parser should decode the ObjectID correctly.

Example :

str = "{\"_id\": \"ObjectId(12345abcd)\"}"
}
Parser.json(str)
> %{"_id" => #ObjectId{ref: "12345abcd"}}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the existing parser entry point and the Parser.json(str) API described in the issue, then trace how the current AST output is produced. The work is done when parsing supports both a JSON object and an AST tree, and the ObjectId(xxxx) representation decodes to BSON.ObjectId rather than a plain string.

Written by the indexing model from the issue text.

Assessment

Tech stack
elixir
Domain
backend, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.