I'm trying to filter through a collection of lists in my router to show a particular list in a new view.
My collection of lists has already been fetched and is saved at MyApp.collections.lists, but when I try to do the following, it returns undefined. (id is a variable that I'm passing in from the router)
var list = MyApp.collections.lists.get(id)
What I don't get is that when I try the exact same code in the browser console, it returns the correct model no problem. I know it's not an issue with .fetch() timing because I log the collection object before and after I try to get the model and it shows up fine. I also know I also tried .getByCid() just to make sure that it wasn't a problem with the id itself and got the same results.
Any ideas what might be causing this?
Related
I'm totally confused.. I finally got the SuiteTalk API working and am able to make authenticated calls from my JS server..
I'm calling the GET /invoice route, which documented here:
https://system.netsuite.com/help/helpcenter/en_US/APIs/REST_API_Browser/record/v1/2022.2/index.html#tag-invoice
Says that it should return to me an InvoiceCollection which is a collection of Invoices which, by the documentation, has all the fields I need as part of an Invoice.
However, the actual response I am getting back is just an array of items that only has the ID in it.. where are all the other invoice fields?!
I tried to just fire off subsequent calls to the /invoice/{id} route with each ID, but I am getting back some of them as unauthorized and some not.. assuming having to do with timestamp being to close together or something.
There has to be a way to call up to /invoice and get all of the data having to do with an invoice and not just the ID right?
I'm also wondering how I can utilize the "Q" param to filter to invoices only for a certain customer, or date, etc. Appreciate any help!
I recommend trying all these queries in postman (netsuite provides a collection for it). If you try it there, you'll see that {{REST_SERVICES}}/record/v1/invoice returns a list of id's and links to invoices.
If you dont see the details of an invoice, can that have something to do with the rights (to that subsidiary)?
e.g. GET: {{REST_SERVICES}}/record/v1/invoice/164198 shows me the entire record.
To get invoices from a certain customer i think i would go for a query in the suiteql restlet.
Hope that helps a bit. I'm just discovering suitetalk myself and it's not the easiest to get a grip of.
I'm working on a Webapp that lets users save ideas.
When a idea gets saved, it is saved in the collection "users" which contains their user uid. Under the users Id is then again a collection named "ideas" created in which finally the ideas get saved.
The problem is, that when i save the idea, everything works fine, but the User ID is greyed out.
This leads to that i can't retrieve the ideas for a user, because the user id document isn't created.
The view in firestore:
The function that i use to create the documents:
The function to retrieve the data:
I can retrieve the ideas of a user correctly, when i create the users id entry manualy.
Do i need to check for the existence of a users document before saving the ideas into it and if it doesn't exists create it?
Or is there a better way im not aware of?
You need to create the user document, otherwise you will create a dangling collection without a parent document.
The id is greyed out, because the document does not actually exist and is only displayed because of the collection under it.
I don't know if this is a bug with Firebase, or maybe it's stated in their documentation, I can't get the IDs from the collection where the document has No fields but Only Subcollection. Please assist me with this. I tried to put some field on some document, then it has shown, then I deleted it again still it shows and I confirmed it's not Cache by opening Incognito on Chrome and still the document was only one showing even though I deleted the field I was testing with. My collection structure looks as on the image attached What I am trying to get is the Ids inside invoices. My current code is I am using Javascript:-
async getMarker() {
const snapshot = await this.db.collection("customer_invoices").get()
return snapshot.docs.map((doc: any) => doc.id);
}
There is no way to query those parent documents, as they don't exist. The console only shows these placeholders so that you can navigate to the subcollections.
The only way I can think of to get these IDs is to do collection group query on all your invoices subcollections, and then find the parent document of each invoice.
Also see:
Get parents from Firestore Collection Group Query, WITHOUT RETRIEVING SONS
Im using Firestore with web javascript sdk.
Assume following scheme:
User Doc -> Friends collection
I want to know when someone change/remove/add data to it.
so what I wrote is something like this:
friendsCollectionRef.onSnapshot(snapshot => {
snapshot.docChanges().forEach(change => {
onChange(change);
});
});
The problem is that whenever I refresh the page, it keeps calling the onChange with data that was updated in my last session..
Is there a way to get only NEW data and not retroactively?
I would like to avoid store "LastUpdate" field on everything.
This, of course, should not be done in client side because then I pay for network which im never going to use..
So storing a boolean isFirstCall in out of the question.
As explained in the doc, when you listen to multiple documents in a collection with the onSnapshot() method:
The first query snapshot contains added events for all existing
documents that match the query. This is because you're getting a set
of changes that bring your query snapshot current with the initial
state of the query.
So each time you refresh your page you are calling again the onSnapshot() method "from scratch" and therefore you get the first query snapshot with all the collection docs.
In other words, I think you will have to implement your "home-made" mechanism to only get the documents you want (probably a "LastUpdate" field...).
You may be interested by this SO answer which shows how to add a createdAt timestamp to a Firestore document via a Cloud Function. You could easily adapt it to record the last update. It would be more complicated if you want to detect the Documents that were deleted since the last fetch.
I'm trying to create a record that is called the same way it's called in our database. I'm trying to create this record from the client with the regular getRecord()-call. The error I get is that I can't do anything on the record, and when I look at the object its isReady is always false.
This is how I'm trying to create the record:
Register (inserts an unique ID in the DB)
Login (front end knows the unique ID)
Login with the Deepstream client (this works)
Create/get the record with client.record.getRecord('path')
It seems like the record is created etc. but the isReady is always false and I can't use the record at all.
I've tried to create a record with a static name and this works as it should.
So, any ideas why I can't create a Deepstream record with an ID from the database?
The ID looks like this: 4d06902a-57f7-4ea8-b76b-f487cb369c5b (I'm using RethinkDB if that makes any difference)
Make sure you are using whenReady(callback) before attempting to use the record. You might also provide an example of statically and dynamically named records you are using.
Are you saying that calling getRecord with the Uid from client.getUid works OK but an id from RethinkDB will not? Please supply the actual error you're seeing or some sample code: http://codeshare.io/