Web應用的高級I/O庫:Fortune.js

Fortune是Web應用程序的一個高級I/O庫。它提供了entity-relationship modelling的一個實現,是無關數據存儲的,可用于實現實時(WebSocket) 和 超媒體應用(RMM Level 3).
示例
Let's build an API that models 推ter's basic functionality:
import fortune from 'fortune'
import http from 'http'
const store = fortune.create()
// The `net.http` function returns a listener function which does content
// negotiation, parses headers, and maps the response to an HTTP response.
const server = http.createServer(fortune.net.http(store))
store.defineType('user', {
name: { type: String },
// Following and followers are inversely related (many-to-many).
following: { link: 'user', inverse: 'followers', isArray: true },
followers: { link: 'user', inverse: 'following', isArray: true },
// Many-to-one relationship of user posts to post author.
posts: { link: 'post', inverse: 'author', isArray: true }
})
store.defineType('post', {
message: { type: String },
// One-to-many relationship of post author to user posts.
author: { link: 'user', inverse: 'posts' }
})
store.connect().then(() => server.listen(1337)) 本文由用戶 nf83 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!