(SOLVED) how to implement bookmarking functionality
- 0
- Flutter
- Databases
- Accounts
- Self Hosted
- Users
i have locations collection and each user can bookmark some locations.
For that i created an another collection called bookmarks and their i have userID which is a relational attribute with many to one and a locations attribute which is also a relational attribute with many to many,
so retrieving all the bookmarks for a specific user is not a problem but i have a problem to get a specific bookmarked location if the user clicks on a location in app and see set the ion accordingly if its bookmarked or not and also want to know how to save and update a location in my collection if a user bookmark a location.
i would be very happy if anybody can give me some suggestion if this approach is good at all and to help me better understand the whole bookmarking a location and the database architecture for it. Thank you.
hi i have problem with relation too
can you share something about your problem?
yes sure. I have implemented or try to implement a bookmarking of a location functionality. I have created a seperate table "locationBookmarks" their i have userID as relational attribute and a locations relational attribute. The problem what i have now that i cannot do any queries on relational attributes thats the one issue and the other issue is if i in general have relationship and somehow want to retrieve a specific bookmarked location i cannot do this at least i dont have any idea how. Overall i also want to know how i implement such functionality. Another idea i also had, that maybe i would have an another table locationBookmarks but without relational attributes just the ids of the locations and each time the user save a location to bookmark it will be a seperate document for that user and their will be then for example if the user bookmarked 10 locations their will be 10 documents with th same userIDs.
In your bookmarks collection did you set the relationship as Two-way? Doing so allows you to access data from either collection from the other. Personally, I'd go with your second approach of creating a locationBookmarks
collection because there are some issues and limitations (queries) with appwrite relationships currently. You'd have to experiment with your use case though.
no i used One-way relationship but yah you right i will go with second option. I still will have the relationship many to one, and can then also do queries on it, so every record in bookmark table will be an actual user and an actual location, but on user and one location pr document. That way by retrieving the DATA i will get the LOCATION and USER object instead of the ids just. I implemented and tested. It works fine, but i have still one issue which is when i toggle bookmark i just do normal document creation and deletion so its not responsive when clicking the bookmark. I dont know how to optimize it.
@Faisal7 Dm me
From what I understand, in such case to try to get the document that has both the user ID and the doc ID. If you can get it they that means it's bookmarked. If you get 0 results, it's not
yes exactly thats how i did with document creation and deletion which means bookmarkd or not bookmarked in my logic but i am checking for the location and userId if its empty or not.
and i also optimized the delation of the bookmark icon changes. 😀
So from what I understand then is that you want it to respond basically instantly?
basically yes if this were the good solution
and it seem that this is the good solution for now i think.
Yes. Current solution is probably the best one. You could try not to get the related things for a faster response and also to give the sensation to user that it's instantly, do the request in the background and show it as bookmarked instantly
yes i also do it like this. i instantly give the user feedback and change the icon accordingly and then do the backend operation as asyncronous and after that i check it again if the operation were succesfull the icon stays as it was and if the operation failed the icon comes to its original position for eaxmple.
(SOLVED) how to implement bookmarking functionality
Recommended threads
- Query Appwrite
Hello, I have a question regarding Queries in Appwrite. If I have a string "YYYY-MM", how can I query the $createdAt column to match this filter?
- Apple OAuth Scopes
Hi Hi, I've configured sign in with apple and this is the response i'm getting from apple once i've signed in. I cant find anywhere I set scopes. I remember se...
- Sign In With Apple OAuth Help
Hi All! I've got a flutter & appwrite app which Im trying to use sign in with apple for. I already have sign in with google working and the function is the sam...