tomas / tomas/needle

query : how to handle nesting in body section of post method

Open
#302 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.6k
Forks
237
PR merge metrics
No merged PRs in 30d

Description

Hi Team,

I have started using 'needle' recently instead of 'request' module. One of the API call (to select data from database) includes complex input:

  1. Database model - simple string
  2. Database input - object or array of objects (with $or, $and operators)

For e.g.

let options = {
    json: true,
    model: "SampleModel",
    _**input: {
                $or: [
                    { where_field1: 'abc' },
                    { where_field2: '123' }
                ]
            }**_
}

'request' was able to handle it properly and fetch the data. But needle gets stuck during the call.

If I pass it a simple object, like shown below, it works.

_**input: { where_field1: 'abc' }**_

How to handle it?

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 at Needle's POST body handling entry point and reproduce issue #302 with the nested $or input, then compare it with the simple object case that works. Check whether the nested object or array is handled differently from the request module; done means the complex input completes successfully without getting stuck.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.