I am working with node-mongodb-drive and i can not use $merge
stage in the aggregate. mongodb throw this error: MongoError: Unrecognized pipeline stage name: '$merge'
.
what can i do?
@Zerka1982 , consider:
NOTEWORTHY
I hope you have strong reasons to enforce such rules. Some emerging TLD and thus, email addresses may well have more that three letters at the end (as the spec suggests)... Which is a concern I have from time to time with online service rejecting .berlin
, .name
, even sometimes .cloud
What is the best way to represent related data in an API response object?
E.g., Say I have an order
object. What method would better represent it (relating to logic and performance)?
Prefixing the keys:
{
"quantity": 2,
"date": 237823872,
"productID": 1
"productName": "iPhone",
"productSlug": "www.site.com/iphone",
"sellerID": 2,
"sellerName": "Apple",
"sellerEmail": "apple.com"
"price": 500.00,
"paymentStatus": "Successful"
}
or nested:
{
"quantity": 2,
"date": 237823872,
"product": {
"id": 1
"name": "iPhone",
"slug": "www.site.com/iphone",
},
"seller": {
"id": 2,
"name": "Apple",
"email": "apple.com"
},
"payment":{
"price": 500.00,
"status": "Successful"
}
}
$ node -v
bash: /home/salathiel/.local/bin/node/bin/node: cannot execute binary file: Exec format error
class myclass {
var carMake = 'Ford'
}
class X { static make = 'Ford'; }
if you want
to summarise, I can instantiate the class and set variables via the constructor but I cannot have just variables in the class which are modified by functions (eg setters and getters)?
I think this would accomplish what you're trying to do:
class Car {
#fuel = 0;
#make;
constructor(make) {
this.#make = make;
}
get make() { return this.#make; }
addFuel(quantity) {
this.#fuel += quantity;
}
}
In this case, #fuel is a private "variable" that can be modified within functions (e.g. the addFuel method). Technically #make is also a variable but I have easily written it in such a way that you cannot modify the make after the car has been constructed (since a Corolla will always be a Toyota) - there is only a getter for the make and no setter, and the #make field is private so it's not exposed to clients.