Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

direct operations on database not reflected on ArangoContext #206

Closed
s0nny7 opened this issue Oct 12, 2020 · 4 comments
Closed

direct operations on database not reflected on ArangoContext #206

s0nny7 opened this issue Oct 12, 2020 · 4 comments
Labels

Comments

@s0nny7
Copy link

s0nny7 commented Oct 12, 2020

How to reproduce: Start spring data arango, go to database web ui and delete collection "X" from ui, then call to collection("X").truncate() will raise an error.

ArangoContext not reflexing the change on database, thus collection("X") not returning null, and no new collection is created automatically.

Expected behavior: Arango detects the change, and create a new collection named "X" automatically so subsequently call to truncate() will success.

@rashtao
Copy link
Collaborator

rashtao commented Oct 12, 2020

There is already an ongoing discussion about collections creation on startup:
#125

The main idea is to optionally create collections and indexes once for all at startup.
So in order to address your needs, I would suggest you implementing such checks in your code, in case using the underlying Java driver directly, eg.:

var collection = template.driver().db(DB).collection(C);
if(!collection.exists())
  collection.create();
collection.truncate();

@s0nny7
Copy link
Author

s0nny7 commented Oct 13, 2020

Thanks, that does work. However my scenario is a bit different, I deleted the database during runtime, so creating collection at startup does not seem like an option for me.

I hope there is an option to invalid the cache on the template level.

@rashtao
Copy link
Collaborator

rashtao commented Oct 14, 2020

I am afraid this is quite an unusual use case that is not addressed by Spring Data.
I would suggest you dealing with it catching the ArangoExceptions related to database/collection not found and recreating db, collections and indexes in such cases.

@rashtao
Copy link
Collaborator

rashtao commented Dec 21, 2020

Closing for now, please reopen if still relevant.

@rashtao rashtao closed this as completed Dec 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants