TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: If JavaScript could talk to databases

3 点作者 photon137超过 12 年前
If JavaScript (or a JS framework) could talk to databases, would we need server-side languages/frameworks at all?

4 条评论

redredraider超过 12 年前
So you want to give clients direct access to your database?
dotborg超过 12 年前
Yes, for offline processing.
评论 #4518443 未加载
geuis超过 12 年前
You can accomplish this, after a sort, using databases like CouchDB and Mongodb.<p>While its entirely possible to write a pure client/database web application, you are going to run into security issues. You are inherently opening up your database to the outside world, and javascript clients are inherently un-trustworthy from a security angle.<p>If I were designing such a platform, I would segment actions into "safe" and "non-safe" areas. Safe areas would be client/database actions that are ok for the javascript client to access externally. Non-safe areas, such as account creation and editing, financial interactions, etc, would need a middle-tier server-side application layer. The middle-tier would need to act as a proxy that handles validation of database requests, etc.
batista超过 12 年前
Yes. For one, you don't let the intertubes (clients) all talk to your database.<p>Second, there are tons of other stuff that we do on the server side besides talking to databases. E.g image processing, task queues, etc.<p>And lastly, Javascript is not the most elegant of languages. No much benefit of using it in the server side, besides the mythical "so we can share code", as if server and client side do the same stuff (with the exception of input validation).
评论 #4518491 未加载