Accessing Database directly

I’m using Ghost headless, is there any downside to accessing the sql db directly? The JS SDK is pretty lacking for relatively simple stuff. Does Ghost run any processes in the background I should be aware of?

The JS SDK is pretty lacking for relatively simple stuff.

Could you elaborate?

Ghost has all kinds of stuff going on in the API and model layer, so you’ll probably get a more frustrating experience trying to access the DB.

Given that everything that’s possible in Ghost Admin is possible via the API, it’s likely that what you want to do is possible just undocumented :slight_smile:

Sure, I am currently trying to query posts by tags and authors. I’m currently using a mysql query to do so using a bunch of inner joins but if ghost has it already made that’d be awesome.

The JS SDK should handle that effortlessly :thinking: Have you seen the docs on filtering?

1 Like

My goodness, that’s my bad! Thanks a lot :slight_smile:. Seperately, I noticed adding members is not supported in the API yet. Is that something I can access the dB directly comfortably about?

As @Hannah mentioned, everything possible in the Ghost Admin is possible via the API, including creating a member, though the members API is not documented since the entire concept is in beta. It’s better if you go through the API since if a breaking change happens, it should error rather than put your db in a bad state. Ghost also integrates with Zapier so you can create members using it as well.

@jackhedaya to be even clearer here - whatever it is you want to do in Ghost, editing the DB directly is pretty much NEVER the right way.

Ghost essentially is an API. Ghost Admin is an API client. Ghost admin never edits the DB directly. If we don’t do it, it should be a pretty clear sign that it’s 1) a bad idea and 2) not necessary.

Members is in beta but there’s an import tool, Zapier integration and undocumented API (because it’s subject to change) which you can use to add members. Although our SDK tools don’t support beta endpoints you can always “learn” the API by inspecting the network tab when using Ghost Admin & write your own code in any language to access the same endpoints.