Firebase fetching data based on a particular key value - rest

I am using firebase real time database. My data is mostly an array of records. For example:
opty = [ {"id":1,"name":"a"}, {"id":2, "name": "b"}]
I can access the entire dataset using:
https://<my project id>.firebaseio.com/opty.json
How do I fetch the record with an id of 2 here? I've tried to do the following:
https://<my project id>.firebaseio.com/opty.json?OptyId=2
but that doesn't work.

If I got you right, you want to filter your data through the rest API.
To achieve that you can use the usual filter parameters as query strings:
https://<my project id>.firebaseio.com/opty.json?orderByKey="id"&startAt=2'
Learn more here.

Related

Referencing JSON payload value in Azure Data Factory for If condition

I have a Json file like so as a payload returned from an API call - which is an http dataset type in data factory.
{
"count": 2,
"name": "DatasetABC",
"columnNames": [
"Column_1",
"Column_2"
],
"rows": ["1234",
"5678"
]
}
I would like to be able to use the count records returned in an If condition. Im wondering what I need to use to get the value of "count" which is 2.
Any help appreciated.
Based on your description, i suppose you could use LookUp Activity in Azure Data Factory.
Lookup activity can retrieve a dataset from any of the Azure Data Factory-supported data sources. Use it in the following scenario:
Dynamically determine which objects to operate on in a subsequent
activity, instead of hard coding the object name. Some object examples
are files and tables. Lookup activity reads and returns the content of
a configuration file or table. It also returns the result of executing
a query or stored procedure. The output from Lookup activity can be
used in a subsequent copy or transformation activity if it's a
singleton value. The output can be used in a ForEach activity if it's
an array of attributes.
For example,maybe you could access the count value by using #{activity('MyLookupActivity').output.firstRow.count} in the IF activity.

Filtering data using rest api fetched from Document library in SharePoint

I am able to fetch the documents that are uploaded into the document library of SharePoint online. Now I want to filter the contents that are getting fetched based on a Lookup column and Choice column. But filter is not working in rest api. Can anyone help here? Below is the part of the url I am using.
/items?$select=,FieldValuesAsText/FileRef&$expand=FieldValuesAsText&$
filter=FieldValuesAsText eq ‘Workbook.xlsx'",
If you want to filter data by file name, we can use the rest api below.
/_api/web/lists/getbytitle('DL')/items?$select=*,FieldValuesAsText&$expand=FieldValuesAsText&$Filter=FileLeafRef eq 'Workbook.xlsx'
If you want to filter data base on lookup field and choice file, we can use this. In my test, the lookup field is "MyLookup" and choice field is "MyChoice".
/_api/web/lists/getbytitle('DL')/items?$select=*,FieldValuesAsText,MyLookup/Title&$expand=MyLookup&$Filter=MyChoice eq 'Choice1' and MyLookup/Title eq 'lookup1'
you can try this one:
/_api/web/Lists('ListGUID')/items?$select=FieldValuesAsText/FileRef&$expand=FieldValuesAsText&$filter=FileLeafRef eq 'filename.txt'

Query related Rest Api in ErpNext

I am trying to fetch data and filter data from erpnext customized site.
When i fetch the fields of the doctype i use the url:- https://runga.rungamatteegroup.com/api/resource/Tea%20Invoice?fields=["name","grade","status","invpr","invsuf","estatename","dop"]
I get the data absolutely fine.
When i fetch the data with filtration, using the url:- https://runga.rungamatteegroup.com/api/resource/Tea%20Invoice/?filters=[["Tea%20Invoice",%20"status",%20"=",%20"Sold%20&%20Delivered"]]
I get the data absolutely fine.
When i try to merge the fields and filter in the url as querystring , i am not able to get it together. the url is :-
https://runga.rungamatteegroup.com/api/resource/Tea%20Invoice/?fields=["status","name","dop"]?filters=[["Tea%20Invoice",%20"status",%20"=",%20"Sold%20&%20Delivered"]]
I am trying this to get the fields of the filtered data only.Because fetching all the data and then filtering will be very hectic.
https://runga.rungamatteegroup.com/api/resource/Tea%20Invoice/?fields=["status","name","dop"]&filters=[["Tea%20Invoice",%20"status",%20"=",%20"Sold%20&%20Delivered"]]
This will work

Parse dashboard - objectId must be a string: ObjectIdHex("56eac5ea1ac8242012ae4ed9")

Recently i migrated all my parse data to MongoLab. i'm saving documents (parse object) directly to mongoDb using MongoClient.save(...), and not using parse SDK.
now mongo generate auto id, in my case - '56eac5ea1ac8242012ae4ed9', and parse dashboard not show any row in this class till i delete this object (document) and i'm getting the next error: objectId must be a string: ObjectIdHex("56eac5ea1ac8242012ae4ed9")
should i save id differently?
how to convert my id to regular Parse object id? (if i reallty need it?)
any solution?
I know parse dashboard is temporary, but right now it helps
It occurs because by default Mongo create an ObjectId for each object stored in its collections. To overcome it, you have to order Mongo store your own generated Id.
You can do it by sending the _id property in your object that is being stored in Mongo. Something like this:
db.collection('_User').save({_id: yourid, ...})
You can generate any random string id, but it would be good to generate the _id as the same way Parse Server does. If you check Parse Server repository (https://github.com/ParsePlatform/parse-server/blob/master/src/cryptoUtils.js) you can find how the id is generated.
Anyway. There are solutions, like www.back4app.com, that already provides full hosting of both parse server, parse dashboard and database
--
Disclosure: I am founder of back4app.com

How to delete only a subset of posted data in firebase

Posting data to firebase generate new items similar to the following example:
log
-K4JVL1PZUpMc0r0xYcw
-K4jVRhOeL7fH6CoNNI8
-K4Jw0Uo0gUcxZ74MWBO
I struggle to find how to e.g. delete entries that is older than x days - preferably with the REST API. Suggestions appreciated.
You can do a range query.
This technique requires you to have a timestamp property for each record.
Using orderBy and endAt you can retrieve all of the items before a specified date.
curl https://<my-firebase-app>.firebaseio.com/category/.json?orderBy="timestamp"&endAt=1449754918067
Then with the result, you can delete each individual item.