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

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

Related

How to define id in POST request using Ravendb

Hello there
I'm having a trouble when I try to insert a document into a Ravendb Server which is running in my other computer. I can retrieve documents easily, but when I try to use REST API with POST request I get this error
"System.ArgumentException","Message":"Query string value 'id' must have a non empty value","Error":"System.ArgumentException: Query string value 'id' must have a non empty value
even though I have my Id defined like this:
{
"id":"adawd",
"name":"genereicname",
"password":"something"
}
Originally I'm making a flutter application but currently I'm just testing the API with Postman.
I messed around with id's (String, int) tried to leave it empty but no luck, does anyone know how to define Id for raven db to send me that sweet 200 response code...
According to the documentation you should use PUT to upload a new document or modify an existing one.
See: https://ravendb.net/docs/article-page/5.2/csharp/client-api/rest-api/document-commands/put-documents

How to use Moodle REST API Call mod_data_add_entry (and parameters)?

I'm trying to set up a webpage that communicates with a Moodle page. I need different data from a database activity and want to create new entries. Note that I am not talking about the SQL database in BG, it is the activity database in courses.
The information should be retrieved/transferred via the REST API, an HTML POST Request. My problem is that I don't know how to add a new record to the database activity because I cannot transfer the data array. Only the first parameter given appears in my database.
E.g. i tried ...&wsfunction=mod_data_add_entry&databaseid=10&data[0][fieldid]=66&data[0][value]=12&data[1][fieldid]=67&data[1][value]=test
And many other combinations. Always only the first parameter is shown in the database.
The docs tell me this (Pseudocode):
//The fields data to be created
list of (
object {
fieldid int //The field id.
subfield string Default to "" //The subfield name (if required).
value string //The contents for the field always JSON encoded.
}
)
Alternatively:
REST (POST parameters)
data[0][fieldid]= int
data[0][subfield]= string
data[0][value]= string
I cannot find anywhere else something called a "subfield".
Any ideas?
Okay, found it. You have to put your values in "", unless they are not a number. Seems like there is a connection with this special activity because you don't have to do it elsewhere.

Cloud Firestore and Ionic

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)

Firebase fetching data based on a particular key value

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.

Using RESTFul Oracle APEX

I am building a mobile App using Appery.io platform which uses MongoDB -based database. I need to link this DB to Oracle database and use APEX to design an interface such that users can query, update the mobile App DB from Oracle as well as Oracle DB can be updated from the mobile App.
In APEX, I use the URI with GET method:
https://api.appery.io/rest/1/db/collections/Outlet_Details/
And I add the header:
X-Appery-Database-Id
When I run the query in the APEX where I insert the Database-Id, APEX shows the table/collection Outlet_Details in JSON format. However, not the entire table is shown due to, I think, the length of CLOB type.
Now my main problem is I need to query this table/collection called Outlet_Details by a column named: _id. So when I use the following URI:
https://api.appery.io/rest/1/db/collections/Outlet_Details/1234
It returns the specific record that ha _id = 1234. However, I do not want to hardcode it. Instead, I need to have more like where condition such that I can query based on any column value (e.g. userId instead _id). The CURL command is as follows:
curl -X GET
-H "X-Appery-Database-Id: 544a5cdfe4b03d005b6233b9"
-G --data-urlencode 'where={"userId ": "1234"}'
https://api.appery.io/rest/1/db/collections/outlet_details/
My problem is how to insert such a command into APEX, specailly (where) part.
In this tutorial, oracle database is used. Hence using where condition with =:DEP condition, and then bind it to a variable is pretty straightforward. However, I need to replicate this tutorial with my MongoDB.
The other question, which I guess would clarify a lot to me, in the aforementioned tutorial, there is a prefix URI that is by default APEX shema URI. Even when I insert different URI template, the resultant URI will append APEX to the one I inserted. How to build a service there using different URI?
I found that APEX takes where condition as encoded parameter in the URL. Something like:
https://api.appery.io/rest/1/db/collections/Outlet_Details?where=%7B%22Oracle_Flag%22%3A%22Y%22%7D
The header is same and no input parameters.
This can be done from Application builder > New Application > Database > Create Application > Shared Componenets > Create > REST and then start inserting the header, utl .. etc.
You can refer to this link as a reference encoded URL