Firestore generates an index create error - google-cloud-firestore

I have a Firestore collection that I'm trying to query. The query generates an index error along with a URL to fix it. The URL looks something like the following:
https://console.firebase.google.com/project/[project-id]/database/firestore/indexes?create_index=EgV1c2VycxoPCgtpbnN0aXR1dGlvbhACGgwKCGxhc3RuYW1lEAIaDQoJZmlyc3RuYW1lEAIaDAoIX19uYW1lX18QAg
When I copy and paste the URL into a browser, I get a Firebase (not Firestore) logo that appears like a butterfly, and then the screen goes blank. When I look at the browser console, I get an uncaught javascript error, actually a whole error object, though this part of it seems most relevant:
"Requested entity was not found"
Meanwhile, when I decode the url's "create_index" key, I get the following:
users
institution
lastname
firstname
__name__
In this list, "users" is the collection, while institution, lastname, and firstname are fields of users. I believe these fields all appear in the collection -- save '__ name __' -- so I'm not quite sure which requested entity isn't found.
Any tips?
Many thanks.

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

Convenient data structure and querying for message application using Firebase Firestore

I've been trying to implement live messaging in my application and I cannot seem to think of a convenient data structure inside Firestore. My current structure looks like this:
collection("conversations").document(id).collection("messages")
Each document holds two attributes user1 and user2 with nicknames of contributors to the conversation. Each document also owns a collection called messages which holds documents where each represents a single message sent with some info.
What I'm trying to do next is to check if the conversation already exists, if not then create it. The problem for me is write a correct query to find out if it exists.
My first idea was: create users array instead which holds nicknames of users and then simply query:
db.collection("conversations").whereField("users", in: ["username1", "username2"])
Problem with this is that it means "where users contains username1 OR username2", but I need it to contain "username1 AND username2".
I tried to be smart and chain the whereField function as following:
db.collection("conversations").whereField("users", arrayContains: "username1").whereField("users", arrayContains: "username2")
Turns out that you cannot use arrayContains more than once in a single query.
After that I came back to the structure as displayed on the screenshot with user1 and user2 and ran a new query:
db.collection("conversations").whereField("user1", isEqualTo: user).whereField("user2", isEqualTo: friend)
This query is ran in a function where user and friend are string parameters holding nicknames of both sender and receiver of the message we're currently sending. Imagine you are sending a message, user is always going to be your nickname and friend the receiver's one. The problem with the query is that you're nickname might be saved under user1 or user2 and receiver's nickname aswell. In either of those situations the conversation exists. How would I have to change the query since I don't know in an advance who will have which position in the query aswell as in Firestore. Running the last query that I included twice while switching user and friend parameter seems very unconvenient.
Any tips or solutions to progress in this problem will be much appreciated!

Filtering by action_target_id on Facebook Ads API

I am using the Facebook Ads API to try to filter out specific action target ids using the follwowing call:
(account-id)/reportstats?date_preset=yesterday&data_columns=["action_target_name","adgroup_id","adgroup_name","spend","actions","adgroup_objective"]&actions_group_by=["action_target_id", "action_destination"]&filters=[{"field": "action_target_id","type": "contains","value": 'insert id'}]
Every time I try to put in a specific ID, I get an empty data set back. Whenever I change the type to "not_contains", I get every piece of data returned. I've also tried the same with action_destination, but it keeps saying value needs to be numeric even though it a string.
It definitely seems like you can filter by action_target_id because when I tried to filter by something random, it told me that filter doesn't exist.
Can anyone help me please?
Unfortunately these values are nested under the actions fields of the results and filters only work on top level field values.

Oracle Apex page canĀ“t fetch data after navigating to another and returning

So i have a form based on one of my table, in wich the id is generated by a function in the database, the username is get from the user in session using the variable :APP_USER and the date has a default value of to_char(sysdate). But the problem is that if I open the page the first time it does work without any error, when I change pages and return to the form I get the error
ORA-01403: no data found
Error Unable to fetch row.
And I don't know why.
If you use the standard fetching process you can check to see which column it uses to fetch a unique row and the item it will use the value from to do this.
If you get the 1403 error then this probably means you are trying to perform a fetch with the value of this page item set to a value which does not exist in the database.
Are you performing a computation on this item? Run plsql code on it? Change it anywhere?
When you get this error, then you can check the session state of the item by clicking "Session" on the developer toolbar. This will show you the session state values of the items, and thus you can see the value of the PK item on which the fetch will operate. If there is an id in there, you can verify whether this value is correct or not.

Spine.js AJAX fetching record from server

I have simple app which displays list of recrods, also user whould be able to edit barticular record by id.
Because list is big, i don't fetch it as whole, but partially via Product.fetch(data: $.param(page: 1)).
Then when someone try to edit record, i call Product.find(id) and if recrord was already prefetched with fetch then it works fine, but when record not yet fetched then i got error like: "Product" model could not find a record for the ID "1152"
So, the question is why find not performing ajax call and how to make it perform it or maybe there is another solution exists ?
Spine.find only looks in the already loaded records. Doing an ajax request isn't the function of find. So you have to try-catch your find and when it gives this error, you have to fetch it.
id = 1152
try
product = Product.find id
catch err
Product.fetch(
data:
id: id
processData: true
)
# Try again after Product.refresh
To be honest, I think this isn't a nice way to do it, but it is how spine works... I rather have it fetch it automatically, or at least not throwing an error on find.