final Data data = ctx.pin(dbName); ctx.unpin(dbName);
Hm, it's difficult what solution will lead you to a correct implementation. I still think it's better not to explicitly call these functions.
ps: If you could point me to some documentation that can help me write better and safer code using BaseX's core classes I would very appreciate.
It's surely worth if you could spend some more time to analyze the implementations of the existing commands. We tried to properly document all functions in the code. If you believe that specific functions need better comments, feel free to give us some concrete hints or (even better) send us a pull request.
Thanks, Christian