Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
ember-data-meta-links-improvements
Advanced tools
Proof of Concept for RFC#160.
This addon is a Proof of Concept for RFC#160 which aims to improve the meta and links situation within Ember Data. The goal is to see how the proposed API solves use cases when used in real applications. The outcome of this addon should be a profound test suite which covers all the use cases of the RFC.
:warning: The current implementation heavily relies on patches of Ember Data internals, so it is definitely not encouraged to use in production, as stability and decent performance can not be guaranteed. :warning:
Currently the following improvements are implemented:
record.ref().meta()
record.ref().meta("response")
hasManyRelationship.ref()
Model#didReceiveData
linkRef.parentRef()
ember install ember-data-meta-links-improvements
// GET /books/1
// {
// data: {
// type: "book",
// id: 1,
// meta: {
// recordLevel: true
// }
// },
// meta: {
// topLevel: true
// }
// }
this.store.findRecord('book', 1).then(function(book) {
// get reference for record
let bookRef = book.ref();
// get record level meta data
let meta = bookRef.meta();
meta === { recordLevel: true };
// get response level meta data
let topLevelMeta = bookRef.meta("response");
topLevelMeta === { topLevel: true };
});
// GET /books/1
// {
// data: {
// type: "book",
// id: 1,
// relationships: {
// chapters: {
// links: {
// related: "related-link",
// self: {
// href: "self-link",
// meta: {
// selfLink: true
// }
// }
// }
// }
// }
// }
// }
this.store.findRecord('book', 1).then(function(book) {
let chaptersRef = book.hasMany("chapters");
let related = chaptersRef.links("related");
related.href() === "related-link";
let next = chaptersRef.links("self");
next.meta() === { selfLink: true };
// GET /self-link
// {
// data: [],
// meta: {
// isSelf: true
// }
// }
next.load().then(function(nextArray) {
nextArray.ref().meta() === { isSelf: true }
});
});
store.query
// GET /books?page=2
// {
// data: [{
// type: "book",
// id: 1
// }],
// links: {
// next: {
// href: "/books?page=3",
// meta: {
// isLast: true
// }
// },
// prev: {
// href: "/books?page=1"
// }
// },
// meta: {
// total: 123
// }
// }
let books = await this.store.query('book', { page: 2 }).then(function(books) {
let booksRef = books.ref();
let prev = booksRef.links("prev");
prev.href() === "/books?page=1";
let next = booksRef.links("next");
next.meta() === { isLast: true };
let meta = booksRef.meta();
meta === { total: 123 };
});
// GET /books?page=3
// {
// data: [{
// type: "book",
// id: 1
// }],
// links: {
// prev: {
// href: "/books?page=2"
// }
// },
// meta: {
// isLastPage: true
// }
// }
let next = await books.ref().links("next").load();
next.ref().meta() === { isLastPage: true }
store.findAll
// GET /books
// {
// data: [{
// type: "book",
// id: 1
// }],
// links: {
// self: "self-link"
// },
// meta: {
// total: 123
// }
// }
let books = await this.store.findAll('book');
let booksRef = books.ref();
let self = booksRef.links("self");
self.href() === "self-link";
let meta = booksRef.meta();
meta === { total: 123 };
// GET /books
// {
// data: [{
// type: "book",
// id: 1
// }],
// meta: {
// total: 456
// }
// }
await this.store.findAll('book', { reload: true });
booksRef.meta() === { total: 456 };
git clone
this repositorynpm install
bower install
ember serve
npm test
(Runs ember try:testall
to test your addon against multiple Ember versions)ember test
ember test --server
ember build
For more information on using ember-cli, visit http://ember-cli.com/.
FAQs
POC for https://github.com/emberjs/rfcs/pull/160
The npm package ember-data-meta-links-improvements receives a total of 2 weekly downloads. As such, ember-data-meta-links-improvements popularity was classified as not popular.
We found that ember-data-meta-links-improvements demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.