is it possible to show specific values from a list in Spinner? - android-spinner

Is it Possible to show specific data in spinner from a List. Here I stuck with the concept. can anyone elaborate me if I can do it or not.
{
"status": "OK",
"message": "Sucess",
"result": [
{
"id": 2,
"name": "DHAKA",
"countryId": "001"
},
{
"id": 4,
"name": "RAJSHAHI",
"countryId": "001"
},
{
"id": 11,
"name": "RANGPUR",
"countryId": "001"
},
{
"id": 6,
"name": "SYLHET",
"countryId": "001"
}
]
}
Here Is my data. I Don't want to show whole list. I just need to know that how will be my approach.

Related

Querying a many to many relationship based on a value

Currently I have a many-to-many relationship between entities. A Transaction contains many persons and a Person contains many Transactions. I'm writing a query to filter out transactions so that the transactions contains the person's name. The problem I'm running into is when I filter based on name, it removes the other Person from the transaction.
Example:
{
"id": 1,
"txnDate": "2021-03-09T12:40:26.000Z",
"persons": [
{
"id": 1,
"name": "Bill"
},
{
"id": 2,
"name": "Jen"
}
]
},
{
"id": 2,
"txnDate": "2021-03-09T12:40:26.000Z",
"persons": [
{
"id": 2,
"name": "Jen"
},
{
"id": 3,
"name": "Bob"
}
]
},
My current query is:
query.leftJoinAndSelect('transaction.persons', 'persons')
.andWhere('persons.name = :name', { name });
where name is a string. If I set name= Bill it results in:
{
"id": 1,
"txnDate": "2021-03-09T12:40:26.000Z",
"persons": [
{
"id": 1,
"name": "Bill"
},
]
},
However, I want it so that when I query by name it would result in:
{
"id": 1,
"txnDate": "2021-03-09T12:40:26.000Z",
"persons": [
{
"id": 1,
"name": "Bill"
},
{
"id": 2,
"name": "Jen"
}
]
},
I'm really stuck and I would love any ideas on how to solve this
Current Stack: Nodejs, TypeORM, TypeScript

How to use QStandardItemModel in PyQt5 to show data from a JSON file into a ListView?

I have a JSON file, I am able to fetch the data. Now, I want to display data into ListView using QStandardItemModel, but I am unable to understand how to implement. Can someone please suggest a basic implementation of how to display data so I have an idea?
Following is JSON file :
[
{
"due": "2019-12-09",
"project": {
"id": 1,
"name": "Volcano"
},
"Assignment_name": [
{
"id": 35,
"name": "Alex"
}
],
"subject": null,
},
{
"due": "2019-10-19",
"project": {
"id": 2,
"name": "Volcanic"
},
"Assignment_name": [
{
"id": 36,
"name": "Alexa"
}
],
"subject": null,
}
]

MongoDB create product summary collection

Say I have a product collection like this:
{
"_id": "5a74784a8145fa1368905373",
"name": "This is my first product",
"description": "This is the description of my first product",
"category": "34/73/80",
"condition": "New",
"images": [
{
"length": 1000,
"width": 1000,
"src": "products/images/firstproduct_image1.jpg"
},
...
],
"attributes": [
{
"name": "Material",
"value": "Synthetic"
},
...
],
"variation": {
"attributes": [
{
"name": "Color",
"values": ["Black", "White"]
},
{
"name": "Size",
"values": ["S", "M", "L"]
}
]
}
}
and a variation collection like this:
{
"_id": "5a748766f5eef50e10bc98a8",
"name": "color:black,size:s",
"productID": "5a74784a8145fa1368905373",
"condition": "New",
"price": 1000,
"sale": null,
"image": [
{
"length": 1000,
"width": 1000,
"src": "products/images/firstvariation_image1.jpg"
}
],
"attributes": [
{
"name": "Color",
"value": "Black"
},
{
"name": "Size",
"value": "S"
}
]
}
I want to keep the documents separate and for the purpose of easy browsing, searching and faceted search implementation, I want to fetch all the data in a single query but I don't want to do join in my application code.
I know it's achievable using a third collection called summary that might look like this:
{
"_id": "5a74875fa1368905373",
"name": "This is my first product",
"category": "34/73/80",
"condition": "New",
"price": 1000,
"sale": null,
"description": "This is the description of my first product",
"images": [
{
"length": 1000,
"width": 1000,
"src": "products/images/firstproduct_image1.jpg"
},
...
],
"attributes": [
{
"name": "Material",
"value": "Synthetic"
},
...
],
"variations": [
{
"condition": "New",
"price": 1000,
"sale": null,
"image": [
{
"length": 1000,
"width": 1000,
"src": "products/images/firstvariation_image.jpg"
}
],
"attributes": [
"color=black",
"size=s"
]
},
...
]
}
problem is, I don't know how to keep the summary collection in sync with the product and variation collection. I know it can be done using mongo-connector but i'm not sure how to implement it.
please help me, I'm still a beginner programmer.
you don't actually need to maintain a summary collection, its redundant to store product and variation summary in another collection
instead of you can use an aggregate pipeline $lookup to outer join product and variation using productID
aggregate pipeline
db.products.aggregate(
[
{
$lookup : {
from : "variation",
localField : "_id",
foreignField : "productID",
as : "variations"
}
}
]
).pretty()

Filter XPath to get list and leave out multiple properties with same property name

Through a XMLImport function in Excel I retrieve a JSON set of data. I would like to retrieve a list of ONLY all the names of the pools (in Example below, only 'Men Singles A' and 'Men Singles B').
Because the array of data has different properties called /name I do not know a way to filter out all the /name properties that are part of the /teams property.
[
{
"poolId": 864,
"position": 0,
"name": "Men Singles A",
"totTeams": 7,
"nrPlayersInTeam": 1,
"teams": {
"6453": {
"id": 6453,
"name": "Peter",
{
"id": 3886,
"name": "Peter",
}
]
},
"6501": {
"id": 6501,
"name": "Jack",
"players": [
{
"id": 3912,
"name": "Jack",
}
]
},
}
},
{
"poolId": 865,
"position": 1,
"name": "Men Singles B",
"totTeams": 22,
"nrPlayersInTeam": 1,
"teams": {
"6406": {
"id": 6406,
"name": "John",
"players": [
{
"id": 3844,
"name": "John",
}
]
},
"6408": {
"id": 6408,
"name": "Matthew",
"players": [
{
"id": 3845,
"name": "Matthew",
}
]
},
}
}
]
When trying the following ImportXML function with a Xpath selection, I get a list of all the /name/ properties found in the JSON array.
=IMPORTXML("https://www.tournia.net/api/v2/test/pools?tournamentUrl=test&_format=xml";"//name")
Retrieved List:
Men Singles A
Peter
Peter
Jack
Jack
Men Singles B
John
John
Mtthew
Matthew
What would be the appropriate XPath code to only get a list of all the pool names?

Query to retrieve every subdocument alone without passing parent id using Mongoose

Here i like to explain my problem.
How can i write a mongoose query to retrieve every subdocument from JSON without passing parent_id.
[
{
"_id": "56a320003fe17cc7363dd0d7",
"name": "Leanna Jacobson",
"gender": "female",
"friends": [
{
"id": 0,
"name": "Riley Case"
},
{
"id": 1,
"name": "Herman Carter"
},
{
"id": 2,
"name": "Pacheco Woodard"
}
]
},
{
"_id": "56a3200001501cfa1ea2641d",
"name": "Juliana Bonner",
"gender": "female",
"friends": [
{
"id": 0,
"name": "Keller Woodward"
},
{
"id": 1,
"name": "Fern Knight"
},
{
"id": 2,
"name": "Cain Richards"
}
]
},
{
"_id": "56a3200006864c78ecb1aeed",
"name": "Gena Stark",
"gender": "female",
"friends": [
{
"id": 0,
"name": "Kate Franco"
},
{
"id": 1,
"name": "Araceli Mcclure"
},
{
"id": 2,
"name": "Molly Nelson"
}
]
},
{
"_id": "56a320006d868155161038b6",
"name": "Eve Gonzalez",
"gender": "female",
"friends": [
{
"id": 0,
"name": "Pam Lang"
},
{
"id": 1,
"name": "Christy Marks"
},
{
"id": 2,
"name": "Donovan Warren"
}
]
},
{
"_id": "56a3200066b94852f5680568",
"name": "Coleman Wooten",
"gender": "male",
"friends": [
{
"id": 0,
"name": "Roberta Olson"
},
{
"id": 1,
"name": "Roseann Reid"
},
{
"id": 2,
"name": "Kerri Russell"
}
]
}
]
Here i need to retrieve every friends details from the subdocument array friends for every parent.
so how can i write query for this?????
Suppose the name of your schema is Person, try this one.
//find all document, only select `friends` field from every document
Person.find({}, 'friends', function (err, friends) {
// the return friends is the [[friends], [friends], ...]
});

Resources