T
T
TRUEC0DER2021-02-21 20:09:58
Node.js
TRUEC0DER, 2021-02-21 20:09:58

How to add an array to the end of a document?

const testsSchema = mongoose.Schema({
    test: {
        id: Number,
        name: String,
        usings: [ Number ]
    }
}, { versionKey: false })
const tests = new test({
                test: {
                    id: count + 1,
                    name: name,
                    usings: []
                }
            })
 return tests.save()

When I add an array to a document, it gets to the very top BPEvDaiG.jpg?download=1&name=%D0%A1%D0%BA%D1%80%D0%B8%D0%BD%D1%88%D0%BE%D1%82%2021-02-2021%2020:10 :53.jpg, and I need to go where I point it myself. Can this be fixed?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Vasilyev, 2021-02-22
@hello_my_name_is_dany

On your client, you can try sorting through Object.keys.
But for the sake of aesthetics, it's not worth it, and in cases where it seems to you that it is the order in the object keys that is needed, often this is due to poor design of the structure of documents / objects / classes, and it is better to reconsider the structure.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question