离线版webapp.如何存储数据? [英] Offline webapp. How to store data?

查看:419
本文介绍了离线版webapp.如何存储数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开发一个网络应用程序来管理体育比赛.它必须能够完全脱机运行,在本地存储数据并在有Internet连接时(可能是第二天)通过AJAX在线发布结果.

I want to develop a webapp to manage sports competitions. It must be able to run completely offline, store data locally and post the results online via AJAX whenever there is an internet connection available - this may be the day after.

如何使用Javascript存储数据?

How to store data using Javascript?

  • 我不想使用任何服务器端技术.
  • 它必须像数据库一样安全.我已经读过关于cookie和html5存储的信息,但是它们都不令人信服.

推荐答案

正是您想要的:

  • 您可以在 IrisCouch 上设置CouchDB实例来存储数据. CouchDB是一个充当Web服务器的数据库,因此它可以根据自己的数据为html页面提供服务-这种对CouchDB(用于服务页面)的使用通常称为了解CouchDB 并编写HTML/Javascript/CouchDB风味的应用来投放您的页面.有工具可以简化此操作.
  • 之后,您只需要将数据发送到您的CouchDB数据库,它就会在您的网页上.您将使用 PouchDB (一种在您的浏览器上运行并在本地保存数据的CouchDB实现)来管理客户端内容.因此,您永远不会丢失它,并会自动更新CouchDB服务器上的本地数据,反之亦然.这是互联网上离线存储的最前沿.
  • 为确保客户端不会将错误数据发送到服务器,您可以设置身份验证(因此,要将Pouch与Couch连接起来,您需要提供密码)或可以设置验证功能(因此服务器将仅接受与您定义的某些参数匹配的数据存储请求).我之前链接的指南(此处)中对这两种方法进行了很好的解释,但是您将在您的CouchDB学习过程中肯定会遇到所有这些问题.
  • You can set up a CouchDB instance on IrisCouch to store your data. CouchDB is a database that acts as a webserver, so it can serve html pages based on its own data -- this use of the CouchDB (to serve pages) is commonly called CouchApp.
  • So you learn about CouchDB and write a HTML/Javascript/CouchDB-flavored app to serve your page. There are tools that facilitate this.
  • After that, you only need to send the data to your CouchDB database and it will be on your web page. You'll manage the client side stuff with PouchDB, a implementation of CouchDB that runs on your browser and saves your data locally, so you never lose it, and automatically updates your local data on the CouchDB server and vice-versa. It's the bleeding edge of the offline storages on the internet.
  • To ensure that the clients will not send bad data to the server, you can set up authentication (so to connect Pouch with Couch you will need to provide a password) or you can set up validation functions (so the server will only accept data storage requests that match certain parameters you define). These two approaches are well explained in the guide I linked before (here), but you will certainly run into all of this during your CouchDB learning process.

很多东西,但是很酷的解决方案足以解决麻烦.另外,这个CouchDB的事情是如此简单,我敢打赌,您将在一两天内阅读和学习所有内容.

A lot of stuff, but a cool solution enough for the trouble. Also, this CouchDB thing is so easy I can bet you'll read and learn everything in one or two days.

这篇关于离线版webapp.如何存储数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆