Show HN: Storex – A modular and portable database abstraction for JavaScript
I have mixed feelings about this.<p>Sharing database abstractions between the client and the server might make sense for some applications, but I worry it might often be a code smell. I used to believe in the dream of sharing models between the client and server, but that illusion was shattered on first contact with reality. With that said, I&#x27;m still open to having my mind changed. I think meteor [0] set out with a similar goal, if not more ambitious, and it doesn&#x27;t appear to have done very well.<p>The limitations are pretty severe, since you&#x27;re basically targeting the lowest common denominator. You cannot reduce the inherent complexity of the problem which these databases set out to solve without sacrificing functionality. My thoughts on this have been all over the place, but lately I&#x27;ve been leaning towards adopting fewer abstraction layers. At some point you&#x27;ll be forced to actually understand each underlying system anyway, and by designing your data models with a specific database in mind you can leverage all of its features to maximum effect in order to achieve optimal performance.<p>It might be useful to review Django&#x27;s ORM design for ideas and inspiration, as they also implement the data mapper pattern. You should consider copying Django&#x27;s migration commands [1] as well.<p>The following refers mostly to server databases, but some of it can apply to client databases as well. You probably shouldn&#x27;t be running migrations automatically, especially in production. We&#x27;re all human and mistakes happen, but there are steps you can take to reduce their potential impact, if not eliminate them entirely within certain processes. Running migrations outside of peak hours reduces the chance you&#x27;ll bump into performance problems and that it&#x27;ll affect users. Always create a snapshot or backup before running migrations, data loss is never acceptable! When a user trusts you with their data it&#x27;s your responsibility to handle it with immense care.<p>This tool doesn&#x27;t help with the more challenging problems related to schema management. Zero-downtime migrations are the industry standard. There&#x27;s a large set of common migration operations which require a full table lock unless they&#x27;re written with deliberate care so as to avoid those pitfalls. Sever-side migrations must always be done in lock-step, with fully backwards-compatible code capable of handling both versions during a transition. Client-side applications are usually expected to remain largely fully compatible with both backwards and future changes.<p>[0] <a href="https:&#x2F;&#x2F;www.meteor.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.meteor.com&#x2F;</a><p>[1] <a href="https:&#x2F;&#x2F;docs.djangoproject.com&#x2F;en&#x2F;2.1&#x2F;topics&#x2F;migrations&#x2F;" rel="nofollow">https:&#x2F;&#x2F;docs.djangoproject.com&#x2F;en&#x2F;2.1&#x2F;topics&#x2F;migrations&#x2F;</a>