Nested database for firebase and react native - database

Was working on a real Estate app that contains three kinds of post, properties for Rent, Sale, and Explore. when i was working with a local file i could access them just fine but now am trying to create the same structure on firebase the problem is the upload form. this is an example of the data structure am trying to create on firebase. how do i go about making a generic form that can upload these kind of data
Data.js
proforsale=[
id: 1,
uploader: "name",
status: "Sale",
photos: []
]
proforrent=[
id: 1,
uploader: "name",
status: "Rent",
photos: []
]
explore=[
]

Related

how to loop my react data, its not showing my data

I makes crud with react but i have trouble when try to displaying from data table. please help me
this my code
my conn to api
this my looping data
looping code
this the console log
console log
I saw that you make an array which contains a lot of arrays. Is this your expectation?
rowsData = [
[{ DocumentID: 1, DocumentName: 2, status: 3, navigation: 4 }],
[{ DocumentID: 1, DocumentName: 2, status: 3, navigation: 4 }]
]

How to convert single ObjectId to an array of ObjectIds in MongoDB Compass

I have a data that is set up like this in MongoDB Compass:
"person": "Isaac",
"city": { "$oid" : "049485053930a029g" }
I need it to be like this below, as a single object can have multiple cities:
"person": "Isaac",
"city": [{ "$oid" : "049485053930a029g" }]
I imported my data with a CSV file.
I tried to use this aggregation in Compass, but I got an error:
{
country: {$objectToArray: "$country"}
}
//$objectToArray requires a document input, found: objectId
WWhat solution can I implement to solve this problem?
I have a lot of data to add to my database, I do not want to do it manually on my back-end CMS.
You can try an update with aggregation pipeline query starting from MongoDB 4.2, to update all the document's city in an array,
db.collection.updateMany(
{},
[{
$set: {
city: ["$city"]
}
}]
)
Playground

MongoDB Loop: Saving data from variable?

Working with a frontend variable like below in javascript with many objects... (Note - the scores would be different for each user therefore I would need to be able to get the info from the frontend)
var campgrounds = [{ name: "State Park #1" score: 0, }, { name: "State Park #2" score: 0, }, { name: "State Park #3" score: 0 }]
How would I be able to store that data in MongoDB? Could I somehow loop through the data? Or could I store the entire variable "campgrounds" in Mongo? like $("#quizData").value(campgrounds)
Would I set up a Schema like below? Even if I did I'm not sure how to actually get the data in the variable into Mongo. Not sure how to accomplish my goal. Thanks for any help! :)
var campgroundsSchema = new Schema ({
"campgrounds" : [{
name : {type: String},
score : {type : Number}
}],
});
If you connect to mongo using mongoshell ...
mongo --host localhost:27017
you can issue the following javascript commands...
use campgroundsdb
var campgrounds = [{ name: "State Park #1", score: 0 }, { name: "State Park #2", score: 0, }, { name: "State Park #3", score: 0 }]
db.campgroundscollection.insertMany(campgrounds)
Then find them by issuing...
db.campgroundscollection.find().pretty()
If you want to create a program written in JavaScript it will need the ability to connect to the mongodb process. Node.js tutorials fit this requirement...
https://www.w3schools.com/nodejs/nodejs_mongodb.asp

(Laravel-Vue) - fetch data in object inside an object using v-for

I'm relatively new in incorporating vue to laravel.
My question is how do I return a data from an object inside an object, using v-for.
Data hierarchy:
{
data: [
{
"project": {
name: "john",
age: "21",
"client": {
name: "stan",
age: 18
}
}
}
]
}
In laravel I incorporate the model relationship (one to manny).
1 client can have many projects.
I'm having a bit of obstacles here. Thanks in advance!

How to get variable price via WooCommerce REST API with ReactJS?

I use ReactJS to build a mobile web app for a WooCommerce shop based on Rest API. Now the question is how to get the price of variation product when selecting the different attributes.
I made a simple demo to descript my issue. https://mofect.com/test
In this demo, after all data is loaded, you can see two options and JSON data in Chrome console, I want to show the final price after set the Size and Color attributes.
I can only get the attributes and variants id from the product Rest API:
{
id: 40
attributes:[
{id: 0, name: "Color", position: 1, visible: true, variation: true}
{id: 0, name: "Size", position: 2, visible: true, variation: true}
]
variations:[106, 107, 108, 109]
}
Then, according to the WooCommerce API documentation http://woocommerce.github.io/woocommerce-rest-api-docs/#list-all-product-variations, I can get all the variations price by product id:
'products/40/variations/'
{
id: 109
attributes:[
{id: 0, name: "Color", option: "White"}
{id: 0, name: "Size", option: "Large"}
],
price: "40"
}
//.... and the other variations arguments
Now the question is how I get variation price from selected attributes?
Any ideas can inspire me would be appreciated!
My source code is available to download here: https://www.dropbox.com/s/yikqwdox47dwo6t/woo-test.zip?dl=0
Thanks!
First, you have to call the products details by the default endpoint of WooCommerce is "/products/41" Where you can get all products details with the variation data.
Variation Data you will get like this:
"variations": [
64,
57,
58,
59
]
Then you can get the product variation by the variation id like this:
/products/41/variations/64
Using this you can get all details of the variation along with the variation image, attributes, price, etc.

Resources