I am using mongodb and odata.
I want to select name field alone for particular user id. (i.e) select name from userdata where userid=1;
/*my collection schema - userdata*/
{
id:number,
userid:string,
name:string,
data:object
}
I tried http://localhost:27017/userdata?$format=json&$filter=userid eq '1'&$select=name
Instead of getting name file alone I got whole object/document that matches userid=1. What I am doing wrong here?
I spoted the problem after the comment from #jps.
The issue is not with query, the problem is with data model which I am using is mismatching with my database schema (i.e) I missed out name field in model, so it is returning whole collection.
Now model is fixed, so the service is responding back with names for given userid.
Related
I'm trying to get a very simple data migration to work, where I want 3 fields from Cosmos Db documents to be inserted as entities in Table Storage.
The challenge seems to be in the fact that I want an Id from the document, also to be the value of the partition key and row key.
I took the Copy data activity, defined Cosmos Db as source, table storage as sink and defined mappings to get the right data into the right field.
In the sink you can specify what to do with partition key and row key.
When I specify the partition key to be the id from the document, it works.
However, when I do the same for row key (instead of a generated identifier), I get this error "The specified AzureTableRowKeyName 'UserId' doesn't exist in the source data".
The weird thing is that there appears to be no problem regarding the partition key for that value.
Any one who can point me in the right direction?
Thanks to #BhanunagasaiVamsi-MT for pointing me in the right direction.
For completeness sake, I'm dropping my solution here, although the link in that post also explains it.
You need to:
specify additional columns, based on the source data
select these colums as rowkey or partitionkey in the sink
assign the additional fields to rowkey and partitionkey in the mapping (feels like a duplicate thing to do, but if you don't you get the error mentioned in the question)
I tried to reproduce the same in my environment and got the same error as below:
If I specify unique identifier its working fine.
Note: Specify the name of the column whose column values are used as the row key. If not specified, use a GUID for each row
For more information refer this Microsoft documentation.
2 Fields on Custom metaData:
Opportunity Field Name
Account Field Name
trigger on opportunity whenever the data of the field get changed (the field that are mentioned in the Custom metadata), then update that field data on the corresponding Account field.
I tried to get Field Values from Custom metaData like Map<Id,Object_Field_Mapping__mdt> metaData = new Map<Id,Object_Field_Mapping__mdt>([SELECT Account_Field_Name__c,Opportunity_Field_Name__c FROM Object_Field_Mapping__mdt]);
And now the problem is I am not able to compare these value with the whole Account object so that i can update on Opportunity.....This sounds little bit confusing but this is what i have to do
Is there any way to compare CustomMetaData Field Value with Account Object..
Someone told me it can be used by Schema/sObjects but I am not sure how
You can use Schema like this
Map<String, Schema.SObjectField> accFields = Schema.getGlobalDescribe().get(objName).getDescribe().fields.getMap();
and you can access its field value like this accFields.values()
for(Schema.SObjectField field : accFields.values())
{
//Some Code here
}
for more information about Schema Class and it's Method please check Schema Class
Hope it Helps
Thanks
How can I get the document id of a collection present in the cloud Firestore?
I tried to get it by using the
firebase.firestore().collection("collectionName").doc().id
but I didn't get the appropriate result.
firebase.firestore().collection("societies").doc().id and it returns a id which is not equivalent to society documentId
That's correct because everytime when you are using the above line of code, you are generating a new document id which will never be the same with one that already exist in your database.
In order to use a new document id, first you need to generate it (as you already do) and then store it in a variable. Having that varaible which holds that id, you can use it to get that particular document from the database by passing this id as an argument to the doc(id) function:
firebase.firestore().collection("societies").doc(this.myId)
I have the following Firebase structure
There is a node that keeps a list of albums by user. In certain circumstances I do not have the user id (E7Bv..), I only have the album id (-L0uG...). If I had both then I could easily access the specific album node.
Since I do not have the userid, i need a way to query the node where the albumin is equal to the value I have in hand. I do not see how to structure such a query.
As one approach I also tried to add the albumid (-L0uG...) to the sub node as the value of _key. I'd prefer not to have to duplicate that value and just query for where the sub-node for albumid equals the value I have in hand for albumid.
Or, if that can not be done then can anyone tell me how to query where the sub-node has a value for _key that matches the value i have in hand - Without knowing the userid node value?
I would like to do something like this ... (where albumRef is the top node for byUser_albums)
albumRef.queryOrdered(byChild: "_key").queryEqual(toValue: albumID).observeSingleEvent(of: .value, with: { snapshot in
of course this fails because _key is not on the userid node, it is on the albumid node. I need to either query by the subnode id, or go deeper to query by _key
UPDATE
From Frank Below. I tried this ...
albumRef.queryOrdered(byChild: albumID).queryStarting(atValue: nil).observeSingleEvent(of: .value, with: { snapshot in
This works and finds the right data. It returns the key of the scoping autoid. The only downside is that Firebase says (in debug log) ....
"**Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding ".indexOn": "-L0vTQtLwBe_hilTOGid" at /byUser_albums to your security rules for better performance**"
If I were doing a typical read then I could just add the rule to the database, but I can't add this rule because the value that it wants the .indexOn is not a static value - it's an auto. I don't see a way to index on the autoid. I think I will have to restructure the albums node to have user as an attribute instead of defining a scoping node by user. I do not see a way to read without downloading all data and filter on the client.
I have access to the database using postgreSQL. There are over 300 tables to look through, and I can't seem to find where to get the project name for a query I want to run. In 'project_task' there is a 'task_name' field. In 'project_phase' there is a 'phase_name' field. But in 'project_project' there doesn't seem to be a 'project_name' field. Seems a bit odd.
project_project does not have a name field. Instead it uses inheritance at the ORM level to get a name from account_analytic_account.
Using SQL, your query will need to join project_project to account_analytic_account using analytic_account_id and get the name field off that table.