I am trying to create databins of dynamics names. But seems that I can only call databin through its shortID, wondering if there is any method to get a databin ID from its name?

Databin[?"name"=="testName"] or some thing like that?

A second related question is how can I test if a databin of a certain name already exists, and if yes, how to get its short ID?



You could create a mapping between the Name and the ShortID of the Databins. E.g.

myBins= Databins[]; 

nameToIdMapping[bins_List] := <|#["Name"] -> #["ShortID"] & /@ bins|>; 
binId= nameToIdMapping[myBins]; 

Then use the mapping when you want to access a specific bin through its name. For example, I have a Databin that collects the credits for an Einstein@Home project.


The second part of your question is then to check the whether a name is part of the Keys for the mapping

MemberQ[Keys@binId, "einsteinAtHome****"]
  • $\begingroup$ Thanks for your answer, but this solution is not the most desired for my case. Because it will be a API function, some call may just create a new databin, where another call is checking if it already exisits. Your solution is more for single thread situation. The best solution for my case is the internal function that allows me to search Databin by name. $\endgroup$ – user1470393 Jan 25 '19 at 15:49
  • $\begingroup$ Ok, will use it as a protected static variable before APIfunction. Thanks for your solution $\endgroup$ – user1470393 Jan 26 '19 at 15:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.