Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
js-data is a framework-agnostic, datastore-agnostic ORM/ODM for Node.js and the Browser.
Adapters allow js-data to connect to various data sources such as Firebase, MySql, RethinkDB, MongoDB, localStorage, Redis, a REST API, etc. With js-data you can re-use your data modeling code between environments, keep your data layer intact when transitioning between app frameworks, and work with a unified data API on the server and the client. js-data employs conventions for rapid development, but allows for endless customization in order to meet your particular needs.
To get started, visit http://js-data.io.
This example shows setting up js-data to use the Http adapter in the browser:
npm i --save js-data js-data-http
See installation instructions for more information.
import {DataStore} from 'js-data'
import HttpAdapter from 'js-data-http'
// Create an empty data store
const store = new DataStore()
// "store" will use an http adapter by default
store.registerAdapter('http', new HttpAdapter(), { 'default': true })
// Define a Mapper for a "user" resource
store.defineMapper('user')
// GET /user/1
let user = await store.find('user', 1)
console.log(user) // { id: 1, name: 'John' }
// The user record is now stored in Users
console.log(store.get('user', user.id)) // { id: 1, name: 'John' }
console.log(user === store.get('user', user.id)) // true
// PUT /user/1 {name:"Johnny"}
user = await store.update('user', user.id, { name: 'Johnny' })
// The user record has been updated, and the change synced to the store
console.log(store.get('user', user.id)) // { id: 1, name: 'Johnny' }
console.log(user === store.get('user', user.id)) // true
// DELETE /user/1
await store.destroy('user', user.id)
// The user instance no longer in the store
console.log(store.get('user', 1)) // undefined
ES5:
// Create an empty data store
var store = new JSData.DataStore()
// "store" will use an http adapter by default
store.registerAdapter('http', new HttpAdapter(), { default: true })
// Define a Mapper for a "user" resource
store.defineMapper('user')
// GET /user/1
store.find('user', 1)
.then(function (user) {
console.log(user) // { id: 1, name: 'John' }
// The user record is now stored in Users
console.log(store.get('user', user.id)) // { id: 1, name: 'John' }
console.log(user === store.get('user', user.id)) // true
// PUT /user/1 {name:"Johnny"}
return await store.update('user', user.id, { name: 'Johnny' })
})
.then(function (user) {
// The user record has been updated, and the change synced to the store
console.log(store.get('user', user.id)) // { id: 1, name: 'Johnny' }
console.log(user === store.get('user', user.id)) // true
// DELETE /user/1
return store.destroy('user', user.id)
})
.then(function () {
// The user instance no longer in the store
console.log(store.get('user', 1)) // undefined
})
Most ORMs/ODMs only work with a single datastore, and most JavaScript ORMs only work in Node.js or the Browser. Wouldn't it be nice if you could use the same ORM/ODM on the client as you do on the backend? Wouldn't it be nice if you could switch databases without having to switch out your data layer code? Enter js-data.
Originally inspired by the desire to have something like Ember Data that worked in Angular.js and other frameworks, js-data was created. Turns out, js-data works in Node.js, so server-side adapters were written. js-data is the Model layer you've been craving. It consists of a convenient framework-agnostic, datastore-agnostic ORM for managing your data, which uses adapters to connect to various persistence layers.
The most commonly used adapter is the http adapter, which is perfect for connecting your frontend to your backend. localStorage, localForage, Firebase and other adapters are available for the browser. On the server you could hook up to the SQL adapter (Postgres/MySQL/MariaDB/SQLite3) or the MongoDB adapter. More adapters are coming, and you're free to implement your own. See Adapters.
js-data and its adapters depend on a global ES2015 Promise
constructor. In
the browser, window.Promise
must be available. In Node.js, global.Promise
must be available. Here is a handy ES2015 Promise polyfill
if you need it.
js-data and its adapters require full ES5 support from the runtime. Here is a handy ES5 polyfill if you need it.
Get started at http://js-data.io
The MIT License (MIT)
Copyright (c) 2014-2016 js-data project authors
FAQs
Robust, framework-agnostic in-memory data store.
The npm package js-data receives a total of 3,943 weekly downloads. As such, js-data popularity was classified as popular.
We found that js-data demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.