Coder Social home page Coder Social logo

aloshai / mongosha Goto Github PK

View Code? Open in Web Editor NEW
27.0 1.0 1.0 124 KB

A fast, optimized and easy-to-use database manager. MongoDB has never been easier! Perfect for beginners!

Home Page: https://www.npmjs.com/package/mongosha

License: MIT License

JavaScript 100.00%
mongodb mongosha database easy-to-use database-manager

mongosha's People

Contributors

aloshai avatar fishuke avatar thearmagan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

thearmagan

mongosha's Issues

Let's get the paths specified in the collections

const result = collection.get("user"); // => [{ "id": 1, "balance": 3 }, { "id": 2, "balance": 300 }, { "id": 13 "balance": 400 }]

const result = collection.get("user.balance"); // => [3, 300, 400];

const result = collection.get("user.balance", "user.id"); // => [{ "id": 1, "balance": 3 }, { "id": 2, "balance": 300 }, { "id": 13 "balance": 400 }]

pullAll method

completely removing an element / data inside the array

Update Elements

Update Elements

A function that can make our work easier should come to the module. (await db.update) It will be able to change the content in any "set" data or "push" data. For example, let's register our data as follows.

await db.set(`hollowking.${message.guild.id}`, {
    Name: "Sude Magda",
    Surname: "ALACATI",
    Points: 15
})

>

hollowking: {
    "795019981493895168": {
        Name: "Sude Magda",
        Surname: "ALACATI",
        Points: 15
    }
}

But our grumpy daughter Magda doesn't seem to like her point. As her caregiver, we have to fix this problem. For this, we need to change the record in a data.

await db.update(`hollowking.${message.guild.id}`, {
    change: {
        Surname: "Wiśniewski"
    },
    add: {
        Points: +5
    },
    remove: {
        Name: "Sude"
    },
    create: {
        Voivodeship: "Warsaw"
    }
})

>

hollowking: {
    "795019981493895168": {
        Name: "Magda",
        Surname: "Wiśniewski",
        Points: 20,
        Voivodeship: "Warsaw"
    }
}

Our grumpy daughter now has 20 points. We have to make a little more change before seeing the very rich father. A list of must-come is listed below.

Change: It changes a data. If used in terms of number, it directly changes the place of the newly entered number without adding or subtracting.

Add: It is used on all types of data. If used on a number, it adds to the number's value. (Of course at the beginning of the number - if any, this is different.) If used on a string value, it performs direct concatenation. (Before: Date, After: Datesing. Adding Date String value to + "sing")

Decrease: It does the subtraction in the same way

Create: It creates a separate data. Although unnecessary for "set" type data, it is very useful for "push" data.

Remove: It deletes a seperate data. Although unnecessary for "set" type data, it is very useful for "push" data.

How will it work for push data?

There will be a value for each push. That is, first data, second data and third data under "push". These data will of course start from 0. The numbers of these data will be processed. For example, there are 15 pushed data under a database. We will have 15 numbers with a starting record from 0.

await db.update(`melcorn.${message.guild.name}[0]`, {
    change: (...)
})

Everything can be very complicated, but I am sure she will bring many changes behind her. "Plus why don't we create a separate record for each data and add or subtract from it more easily?" The best answer to the question may be speed and convenience. At the same time, keeping less data and gathering all data under one roof is an adequate answer.

With love!

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.