Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ember.js 使用pushObject后如何回滚未限制的关系?_Ember.js_Ember Data - Fatal编程技术网

Ember.js 使用pushObject后如何回滚未限制的关系?

Ember.js 使用pushObject后如何回滚未限制的关系?,ember.js,ember-data,Ember.js,Ember Data,给定一个标签和post多个关系,定义如下: post.js tag.js 使用pushObject将标记添加到post时 let aPost = this.store.findRecord('post', 1), aTag = this.store.findRecord('tag', 1); aPost.get('tags').pushObject(aTag); // aPost is not commited yet 如何将标签恢复到初始状态 import Ember from

给定一个
标签
post
多个关系,定义如下:

post.js

tag.js

使用
pushObject将
标记添加到
post

let aPost = this.store.findRecord('post', 1),
    aTag  = this.store.findRecord('tag', 1);

aPost.get('tags').pushObject(aTag); // aPost is not commited yet
如何将标签恢复到初始状态

import Ember from 'ember';
import Model from 'ember-data/model';
import { hasMany } from 'ember-data/relationships';

export default Model.extend({
  posts: hasMany('post')
}
let aPost = this.store.findRecord('post', 1),
    aTag  = this.store.findRecord('tag', 1);

aPost.get('tags').pushObject(aTag); // aPost is not commited yet