Spine.js AJAX fetching record from server - coffeescript

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.

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

Firestore generates an index create error

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.

How to save one value of Parse object without overwriting entire object?

I have two users accessing the same object. If userA saves without first fetching the object to refresh their version, data that userB has already successfully saved would be overwritten. Is there any way(perhaps cloud code?) to access and update one, and only one, data value of a PFObject?
I was thinking about pushing the save out to the cloud, refreshing the object once it gets there, updating the value in the cloud, and then saving it back. However that's a pain and still not without it's faults.
This seems easy enough, but to me was more difficult than it should have been. Intuitively, you should be able to filter out the fields you don't want in beforeSave. Indeed, this was the advice given in several posts on Parse.com. In my experience though, it would actually treat the filtering as deletions.
My goal was a bit different - I was trying to filter out a few fields and not only save a few fields, but translating to your context, you could try querying the existing matching record, and override the new object. You can't abort via response.failure(), and I don't know what would happen if you immediately save the existing record with the field of interest and null out the request.object property - you could experiment on your own with that:
Parse.Cloud.beforeSave("Foo", function(request, response) {
// check for master key if client is not end user etc (and option you may not need)
if (!request.master) {
var query = new Parse.Query("Foo");
query.get(request.object.id).then(function(existing) {
exiting.set("some_field", request.object.get("some_field"));
request.object = exiting; // haven't tried this, otherwise, set all fields from existing to new
response.success();
}, function(error) {
response.success();
});
}
});

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.