How to get exact database match with Symfony and Docrtrine - symfony

i have a strange problem. I dont get an exact match of my user.
when i make an api request with the following json body:
{
"userId": "2ab"
}
i search if there is any user with this (int)id the expected result have to be null. But i get a user with id 2. Is there a way to get only results with the given alphanumeric id which can be a real userId or any temporär alphanumeric id? guests in this case get a random alphanumeric id while users have their real id.
Or do i have to solve this by another way?

Related

Cosmos DB simple ID field for end user

Is it possible to include a user friendly ID field into cosmos db documents? This doesn't need to override the default id field that generates when adding a document but can be a custom one that is simple for an end user to know and search for.
Example document, the ref field is what I want to generate as a simple human readable identifier.
{
"id": "57275754475457-5445444-44420478",
"ref": "45H7GI",
"userId": "48412",
"whenCreated": "D2021-11-09T21:56:31.630",
"tenantId": "5566HH"
}
I'm looking at building a ticketing system and would like a simple ID field for a user to be sent and who can reference when updating/ searching for.
Any help with this would be appreciated.
For your own purposes, you can choose to either use id (which is guaranteed to be unique within a partition) or your own property (such as ref as you defined in your example). For any property other than id, you'd need to add a unique-key constraint when creating the container (and at that point, ref would be unique within any partition, just like id).
Really your choice whether you store your custom id's in id or ref. Just know that, if you ever want to do a direct-read (instead of a query), you can only do a direct-read against an id, not against any other property.

How to get a specific user data with the help of uid?

My question is based on this one:
Retrieve specific user data from firebase in flutter.
There is answer how to get user data using user id, but I don't know how to get some specific user data, e.g. how to get name or age.
Summary:
Every user has unique id and name, age, address.
I have user id and I want to get another user data, e.g. I want to get name of that user. How?
Create a collection named users,this collection will have many documents by the name of userIds, each document will have Map-like structure e.g. "name":string, 'age":int, 'address':string . Since you have the id from firebase login , just DocumentSnapshot document = await Firestore.instance.collection("/userdata").document("uid").get();
From there you could construct your user class or use document['name'] immediately
If what you mean is that you would like to make something like SELECT x,y,z i have to say you cannot..
You have to first retreive the document by its uniqueId then you can read specifica data

Firebase Collection Group Query on Id / Key [duplicate]

This question already has an answer here:
How to perform collection group query using document ID in Cloud Firestore
(1 answer)
Closed 2 years ago.
I have been following along the following document:
https://firebase.google.com/docs/firestore/query-data/queries#collection-group-query
My data structure roughly looks like this:
/teams/{teamid}
{
displayName: "Company X Team",
owner: "userid",
}
/teams/{teamid}/invites/{emailAddressAsKey}
{
someProp: "my data"
}
In my web app I want to search through all the different teams records to find an invite who's id/key is equal to the email address that I pass in. After reading through the documentation, I think a Collection Group Query is what I'm looking for. However, my situation doesn't exactly match the example. I want to match on the key, not a prop within the document. I suppose I could add the email address again as a prop, but that doesn't feel right.
You have to put the document ID as a key in the document itself. There is currently no other solution.
It's tempting to use FieldPath.documentId() in a where clause (eg following Alex Mamo's answer https://stackoverflow.com/a/56967352/2518722), but that doesn't work in the general case. The reason is that FieldPath.documentId() actually refers to the full, unique ID of the document including its path.
If you do try this you'll get the following error:
Error: When querying a collection group and ordering by
FieldPath.documentId(), the corresponding value must result in a valid
document path, but '<your doc id>' is not because it contains an odd
number of segments.
Basically the where clause only works with searches on keys/values not document IDs.
You can solve this with the help of FieldPath.documentId() like in the following line of code:
db.collectionGroup('teams').where(firebase.firestore.FieldPath.documentId(), '==', 'teams/teamId').get()
This query will return all documents with a specific team id.

How to handle different-case usernames in Firebase?

I'm having an issue with Firebase DB involving case sensitive keys. For example: I create a "Username" key for every new user that registers. I'm validating this "Username" value through regex and also checking if the value entered already exists in the database (checking username availability). My issue is that I just realized Firebase assumes different sentence case of the same value is a different value.
For example:
"Username": john and
"Username": John are seen as two different/unique usernames
I was thinking taking the user's desired username input string and making it all caps (or all lowercase), creating uniformity in the database, but then it would kill the ability of having a mixed-case username. Is there a way to bypass this?
I had the same issue using firebase. The solution was create a new property with lowercase for "searchable" fields on my system. Also I remove the accents from words on this property.

What is the format of the LinkedIn id field r_basicprofile?

We make use of Sign in with LinkedIn for a pre-existing app. The app uses the id field returned as part of the user's profile, however the app has restrictions on what character values can be present in the id.
What are the legal characters that LinkedIn will put in the id?
The description for id says
A unique identifying value for the member.
This value is linked to your specific application. Any attempts to use it with a different application will result in a "404 - Invalid member id" error.
Testing a small sample size, shows things like zHjkl_t-4D, _IcF7_r2b1 and -1ZM8mwCKM, which caused an issue with the field being restricted to starting with alphanumeric characters. I'd like to know the legal values so we can access if LinkedIn signups are suitable for future applications.
Member IDs are presented in Base64 encoded format. Any characters that show up in the Base64 index table are valid.

Resources