Giter VIP home page Giter VIP logo

Comments (3)

mormahr avatar mormahr commented on May 14, 2024

I would not consider this to be the responsibility of this library. It has nothing to do with the specifics of mongodb.

And a conversion function could be as simple as

function convert(obj) {
    if (typeof obj !== "object") {
        // "ignore" non object values
        return obj
    }
    
    const keys = Object.keys(obj)
    if (keys.length > 0) {
        // copy all properties over while converting them
        const clone = {}
        for (const key of keys) {
            clone[key] = convert(obj[key])
        }
        return clone
    } else {
        return 1
    }
}

no guarantees, of course

from graphql-fields.

robrichard avatar robrichard commented on May 14, 2024

Yes I agree with @mormahr. You can easily check if it's a leaf node by using Object.keys

from graphql-fields.

furkanedu avatar furkanedu commented on May 14, 2024

Since there is no specific reason for end leafs to be empty object, it could be handful if possible. Anway I already stopped using this library, because of other problems related to mongodb. Thanks for your answers and time.

from graphql-fields.

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.