2 small coding jobs with Node.js, Javascript, mongoose, mongoDB
$10-30 USD
Finalizat
Data postării: peste 3 ani în urmă
$10-30 USD
Plata la predare
See description below or easier to read in attached file.
The following assignment is small and just looks huge.
The following description is just very detailed to make sure that no misunderstandings arise.
I'm using node.js with express, mongoose and mongodb and have some user documents in my mongodb user collection. The documents do also have nested values and arrays.
Please see one representative and simplified example for one user document in mongoDB user collection:
user = [
{
_id: ObjectId("xyz2"),
property: Array
0: "A"
1: "B"
2: "C"
3: "S"
4: "N"
userId: "userId1",
contactDetails: Object
companyName: Array
0: Object
date:2020-08-23T11:52:48.535+00:00
_id: ObjectId("xyz")
name:"companyA"
1: Object
date:2020-08-24T11:52:48.535+00:00
_id: ObjectId("xyz")
name:"companyB"
firstName: Array
0: Object
date:2020-08-23T11:52:48.535+00:00
_id: ObjectId("xyz")
name:"firstName0"
1: Object
date:2020-08-24T11:52:48.535+00:00
_id: ObjectId("xyz")
name:"firstName1"
2: Object
date:2020-08-24T11:52:48.535+00:00
_id: ObjectId("xyz")
name:"firstName2"
3: Object
date:2020-08-24T11:52:48.535+00:00
_id: ObjectId("xyz")
name:"firstName3"
secondName: Array
0: Object
date:2020-08-23T11:52:48.535+00:00
_id: ObjectId("xyz")
name:"secondName0"
1: Object
date:2020-08-24T11:52:48.535+00:00
_id: ObjectId("xyz")
name:"secondName1"
2: Object
date:2020-08-24T11:52:48.535+00:00
_id: ObjectId("xyz")
name:"secondName2"
}]
The lengths of the arrays secondName and firstName is unknown. Can be 0, 1, can be 3, can be 67, ...
Assignment number 1:
Code an efficient solution to check if document with ObjectId xyz2 has at least one Object in secondName AND (&&) firstName.
The result shall be boolean true or false. I like to check if user provided first name and second name after resgistration.
If both are not provided, means not minimum one object in each, boolean shall be fullName = false.
For the above example above it should be fullName = true.
Assignment number 2:
This assignement must consist of two steps. Not one (function).
1th Step)
Now, I like to find all users/documents in user collection by property "N". So maybe something like this:
const allUserN = await [login to view URL]({ property: { $in: ["N"] } }) ...
But I don't like to list the entire content of each found document. Only the following:
- userId
- latest name in secondName array (Example above secondName2)
- latest name in firstName array (Example above firstName3)
So only list an array called "allUserN" with all N documents with only the three key value pairs above.
2th Step)
Then, in a second step (not everything in one function), manipulate and restructure the array from 1th step so that I can use it for React Select ([login to view URL])
This means: Rename / create new keys by using firstName secondName for label and userId for value. Result (for example four found documents):
const allUserN2 = [
{ value: "xyz2", label: "firstName3 secondName2" },
{ value: "...", label: "..." },
{ value: "...", label: "..." },
{ value: "...", label: "..." },
];
In the end two steps/solutions/functions/actions/whatever are needed.
After providing your solution I will try it and if it works I release the payment. If not working, I can ask you. In worst case, we can use anydesk.
In case of questions, you can ask me and I you.
NO Scammers and NO bargaining and No Asking for tip after contract approval!
Only efficient JS solution with smalest possible performance need.
No JQuery. No further packages. Only JS.
Hi there,
Let's have quick talk to get more details from you,
& make it exactly like you want 100% -- expert MongoDB/Express/JS/
of course, will using JS only..
I've been optimizing Mongo queries for years, this seems like a fun project. I do comment my complex queries so you'll have a reference to do this in the future.
Und Ich kann ein bisschen Deutsch sprechen - wenn das wichtig ist. :)