代码如下:
var query = new AV.Query('StuCouMap');
query.include('student');//此处用了include
query.find().then(function(res){
for(var i in res){
var res=res[i];
var student=res.get('student');
var qiandaoNow=res.get('qiandaoNow');
console.log(student);
console.log(qiandaoNow);
}
});
var query = new AV.Query('StuCouMap');//相同的代码,没用include
query.find().then(function(res){
for(var i in res){
var res=res[i];
var student=res.get('student');
var qiandaoNow=res.get('qiandaoNow');
console.log(student);
console.log(qiandaoNow);
}
});
console的结果
"Please use AV.init() to replace AV.initialize() ."
第一次的结果:
undefined //(student没了 why?????)
[object Object] {
beizhu: "身体不适",
dateleaver: [object Date] { ... },
values: 3
}
第二次的结果
[object Object] { //student存在 why????
_applyOpSet: function (t,n){var r=this;e._objectEach(t,function(t,i){n[i]=t._estimate(n[i],r,i),n[i]===e.Op._UNSET&&delete n[i]})},
_canBeSerialized: function (){return e.Object._canBeSerializedAsValue(this.attributes)},
_cancelSave: function (){var t=r.first(this._opSetQueue);this._opSetQueue=r.rest(this._opSetQueue);var n=r.first(this._opSetQueue);e._objectEach(t,function(e,r){var i=t[r],s=n[r];i&&s?n[r]=s._mergeWithPrevious(i):i&&(n[r]=i)}),this._saving=this._saving-1},
_escapedAttributes: [object Object] { ... },
_fetchWhenSave: false,
_finishFetch: function (t,n){this._opSetQueue=[{}],this._mergeMagicFields(t);var r=this;e._objectEach(t,function(t,n){r._serverData[n]=e._decode(n,t)}),this._rebuildAllEstimatedData(),this._refreshCache(),this._opSetQueue=[{}],this._hasData=n},
_finishSave: function (t){var n={};e._traverse(this.attributes,function(t){t instanceof e.Object&&t.id&&t._hasData&&(n[t.id]=t)});var i=r.first(this._opSetQueue);this._opSetQueue=r.rest(this._opSetQueue),this._applyOpSet(i,this._serverData),this._mergeMagicFields(t);var s=this;e._objectEach(t,function(t,r){s._serverData[r]=e._decode(r,t);var i=e._traverse(s._serverData[r],function(t){return t instanceof e.Object&&n[t.id]?n[t.id]:void 0});i&&(s._serverData[r]=i)}),this._rebuildAllEstimatedData(),this._saving=this._saving-1},
_getSaveJSON: function (){var t=r.clone(r.first(this._opSetQueue));return e._objectEach(t,function(e,n){t[n]=e.toJSON()}),t},
_hasData: false,
_hashedJSON: [object Object] { ... },
_mergeMagicFields: function (t){var n=this,i=["id","objectId","createdAt","updatedAt"];e._arrayEach(i,function(i){t[i]&&("objectId"===i?n.id=t[i]:"createdAt"!==i&&"updatedAt"!==i||r.isDate(t[i])?n[i]=t[i]:n[i]=e._parseDate(t[i]),delete t[i])})},
_opSetQueue: [[object Object] { ... }],
_pending: [object Object] { ... },
_previousAttributes: [object Object] { ... },
_rebuildAllEstimatedData: function (){var t=this,n=r.clone(this.attributes);this.attributes=r.clone(this._serverData),e._arrayEach(this._opSetQueue,function(n){t._applyOpSet(n,t.attributes),e._objectEach(n,function(e,n){t._resetCacheForKey(n)})}),e._objectEach(n,function(e,n){t.attributes[n]!==e&&t.trigger("change:"+n,t,t.attributes[n],{})}),e._objectEach(this.attributes,function(e,i){r.has(n,i)||t.trigger("change:"+i,t,e,{})})},
_rebuildEstimatedDataForKey: function (t){var n=this;delete this.attributes[t],this._serverData[t]&&(this.attributes[t]=this._serverData[t]),e._arrayEach(this._opSetQueue,function(r){var i=r[t];i&&(n.attributes[t]=i._estimate(n.attributes[t],n,t),n.attributes[t]===e.Op._UNSET?delete n.attributes[t]:n._resetCacheForKey(t))})},
_refreshCache: function (){var t=this;t._refreshingCache||(t._refreshingCache=!0,e._objectEach(this.attributes,function(n,i){n instanceof e.Object?n._refreshCache():r.isObject(n)&&t._resetCacheForKey(i)&&t.set(i,new e.Op.Set(n),{silent:!0})}),delete t._refreshingCache)},
_resetCacheForKey: function (t){var n=this.attributes[t];if(r.isObject(n)&&!(n instanceof e.Object)&&!(n instanceof e.File)){n=n.toJSON?n.toJSON():n;var i=JSON.stringify(n);if(this._hashedJSON[t]!==i){var s=!!this._hashedJSON[t];return this._hashedJSON[t]=i,s}}return!1},
_serverData: [object Object] { ... },
_silent: [object Object] { ... },
_startSave: function (){this._opSetQueue.push({})},
_toFullJSON: function (t){var n=r.clone(this.attributes);return e._objectEach(n,function(r,i){n[i]=e._encode(r,t)}),e._objectEach(this._operations,function(e,t){n[t]=e}),r.has(this,"id")&&(n.objectId=this.id),r.has(this,"createdAt")&&(r.isDate(this.createdAt)?n.createdAt=this.createdAt.toJSON():n.createdAt=this.createdAt),r.has(this,"updatedAt")&&(r.isDate(this.updatedAt)?n.updatedAt=this.updatedAt.toJSON():n.updatedAt=this.updatedAt),n.__type="Object",n.className=this.className,n},
_toPointer: function (){return{__type:"Pointer",className:this.className,objectId:this.id}},
_validate: function (e,t){if(t.silent||!this.validate)return!0;e=r.extend({},this.attributes,e);var n=this.validate(e,t);return n?(t&&t.error?t.error(this,n,t):this.trigger("error",this,n,t),!1):!0},
add: function (t,n){return this.set(t,new e.Op.Add([n]))},
addUnique: function (t,n){return this.set(t,new e.Op.AddUnique([n]))},
attributes: [object Object] { ... },
bind: function (e,n,r){var i,s,o,a,u;if(!n)return this;for(e=e.split(t),i=this._callbacks||(this._callbacks={}),s=e.shift();s;)u=i[s],o=u?u.tail:{},o.next=a={},o.context=r,o.callback=n,i[s]={tail:a,next:u?u.next:o},s=e.shift();return this},
change: function (t){t=t||{};var n=this._changing;this._changing=!0;var i=this;e._objectEach(this._silent,function(e){i._pending[e]=!0});var s=r.extend({},t.changes,this._silent);if(this._silent={},e._objectEach(s,function(e,n){i.trigger("change:"+n,i,i.get(n),t)}),n)return this;for(var o=function(e,t){i._pending[t]||i._silent[t]||delete i.changed[t]};!r.isEmpty(this._pending);)this._pending={},this.trigger("change",this,t),e._objectEach(this.changed,o),i._previousAttributes=r.clone(this.attributes);return this._changing=!1,this},
changed: [object Object] { ... },
changedAttributes: function (t){if(!t)return this.hasChanged()?r.clone(this.changed):!1;var n={},i=this._previousAttributes;return e._objectEach(t,function(e,t){r.isEqual(i[t],e)||(n[t]=e)}),n},
cid: "c10",
className: "UserLX",
clear: function (e){e=e||{},e.unset=!0;var t=r.extend(this.attributes,this._operations);return this.set(t,e)},
clone: function (){return new this.constructor(this.attributes)},
constructor: function (){e.apply(this,arguments)},
destroy: function (e){e=e||{};var t=this,n=function(){t.trigger("destroy",t,t.collection,e)};if(!this.id)return n();e.wait||n();var r=s("classes",this.className,this.id,"DELETE",null,e.sessionToken);return r.then(function(){return e.wait&&n(),t})._thenRunCallbacks(e,this)},
dirty: function (e){this._refreshCache();var t=r.last(this._opSetQueue);return e?t[e]?!0:!1:this.id?r.keys(t).length>0?!0:!1:!0},
escape: function (e){var t=this._escapedAttributes[e];if(t)return t;var n,i=this.attributes[e];return n=o.isNullOrUndefined(i)?"":r.escape(i.toString()),this._escapedAttributes[e]=n,n},
existed: function (){return console.warn("AV.Object.prototype.existed() is deprecated."),!1},
fetch: function (){var e={},t={};1===arguments.length?e=arguments[0]:2===arguments.length&&(t=arguments[0],e=arguments[1]||{}),t&&t.include&&r.isArray(t.include)&&(t.include=t.include.join(","));var n=this,i=s("classes",this.className,this.id,"GET",t,e.sessionToken);return i.then(function(e){return n._finishFetch(n.parse(e),!0),n})._thenRunCallbacks(e,this)},
fetchWhenSave: function (e){if(console.warn("AV.Object#fetchWhenSave is deprecated, use AV.Object#save with options.fetchWhenSave instead."),!r.isBoolean(e))throw"Expect boolean value for fetchWhenSave";this._fetchWhenSave=e},
get: function (e){switch(e){case"objectId":return this.id;default:return void 0===this.attributes[e]?this[e]:this.attributes[e]}},
getACL: function (){return this.get("ACL")},
getCreatedAt: function (){return this.createdAt||this.get("createdAt")},
getObjectId: function (){return this.id},
getUpdatedAt: function (){return this.updatedAt||this.get("updatedAt")},
has: function (e){return!o.isNullOrUndefined(this.attributes[e])},
hasChanged: function (e){return arguments.length?this.changed&&r.has(this.changed,e):!r.isEmpty(this.changed)},
id: "59acab378d6d8100574a0a7b",
increment: function (t,n){return(r.isUndefined(n)||r.isNull(n))&&(n=1),this.set(t,new e.Op.Increment(n))},
initialize: function (){},
isNew: function (){return!this.id},
isValid: function (){return!this.validate(this.attributes)},
off: function (e,n,r){var i,s,o,a,u,c;if(s=this._callbacks){if(!(e||n||r))return delete this._callbacks,this;for(e=e?e.split(t):_.keys(s),i=e.shift();i;)if(o=s[i],delete s[i],o&&(n||r)){for(a=o.tail,o=o.next;o!==a;)u=o.callback,c=o.context,(n&&u!==n||r&&c!==r)&&this.on(i,u,c),o=o.next;i=e.shift()}return this}},
on: function (e,n,r){var i,s,o,a,u;if(!n)return this;for(e=e.split(t),i=this._callbacks||(this._callbacks={}),s=e.shift();s;)u=i[s],o=u?u.tail:{},o.next=a={},o.context=r,o.callback=n,i[s]={tail:a,next:u?u.next:o},s=e.shift();return this},
op: function (e){return r.last(this._opSetQueue)[e]},
parse: function (t){var n=r.clone(t);return r(["createdAt","updatedAt"]).each(function(t){n[t]&&(n[t]=e._parseDate(n[t]))}),n.updatedAt||(n.updatedAt=n.createdAt),n},
previous: function (e){return arguments.length&&this._previousAttributes?this._previousAttributes[e]:null},
previousAttributes: function (){return r.clone(this._previousAttributes)},
relation: function (t){var n=this.get(t);if(n){if(!(n instanceof e.Relation))throw"Called relation() on non-relation field "+t;return n._ensureParentAndKey(this,t),n}return new e.Relation(this,t)},
remove: function (t,n){return this.set(t,new e.Op.Remove([n]))},
save: function (t,n,i){var a,u,c;if(r.isObject(t)||o.isNullOrUndefined(t)?(a=t,c=n):(a={},a[t]=n,c=i),!c&&a){var l=r.reject(a,function(e,t){return r.include(["success","error","wait"],t)});if(0===l.length){var h=!0;if(r.has(a,"success")&&!r.isFunction(a.success)&&(h=!1),r.has(a,"error")&&!r.isFunction(a.error)&&(h=!1),h)return this.save(null,a)}}c=r.clone(c)||{},c.wait&&(u=r.clone(this.attributes));var f=r.clone(c)||{};f.wait&&(f.silent=!0);var d;if(f.error=function(e,t){d=t},a&&!this.set(a,f))return e.Promise.error(d)._thenRunCallbacks(c,this);var p=this;p._refreshCache();var _=[],m=[];return e.Object._findUnsavedChildren(p.attributes,_,m),_.length+m.length>0?e.Object._deepSaveAsync(this.attributes,p,c).then(function(){return p.save(null,c)},function(t){return e.Promise.error(t)._thenRunCallbacks(c,p)}):(this._startSave(),this._saving=(this._saving||0)+1,this._allPreviousSaves=this._allPreviousSaves||e.Promise.as(),this._allPreviousSaves=this._allPreviousSaves._continueWith(function(){var t=p.id?"PUT":"POST",n=p._getSaveJSON();if(p._fetchWhenSave&&(n._fetchWhenSave=!0),c.fetchWhenSave&&(n._fetchWhenSave=!0),c.query){var i;if("function"==typeof c.query.toJSON&&(i=c.query.toJSON(),i&&(n._where=i.where)),!n._where){var o=new Error("options.query is not an AV.Query");return e.Promise.error(o)._thenRunCallbacks(c,p)}}var l="classes",h=p.className;"_User"!==p.className||p.id||(l="users",h=null);var d=c._makeRequest||s,_=d(l,h,p.id,t,n,c.sessionToken);return _=_.then(function(e){var t=p.parse(e);return c.wait&&(t=r.extend(a||{},t)),p._finishSave(t),c.wait&&p.set(u,f),p},function(t){return p._cancelSave(),e.Promise.error(t)})._thenRunCallbacks(c,p)}),this._allPreviousSaves)},
set: function (t,n,i){var s;if(r.isObject(t)||o.isNullOrUndefined(t)?(s=t,e._objectEach(s,function(t,n){s[n]=e._decode(n,t)}),i=n):(s={},s[t]=e._decode(t,n)),i=i||{},!s)return this;s instanceof e.Object&&(s=s.attributes),i.unset&&e._objectEach(s,function(t,n){s[n]=new e.Op.Unset});var a=r.clone(s),u=this;if(e._objectEach(a,function(t,n){t instanceof e.Op&&(a[n]=t._estimate(u.attributes[n],u,n),a[n]===e.Op._UNSET&&delete a[n])}),!this._validate(s,i))return!1;this._mergeMagicFields(s),i.changes={};var c=this._escapedAttributes;this._previousAttributes||{};return e._arrayEach(r.keys(s),function(t){var n=s[t];n instanceof e.Relation&&(n.parent=u),n instanceof e.Op||(n=new e.Op.Set(n));var o=!0;n instanceof e.Op.Set&&r.isEqual(u.attributes[t],n.value)&&(o=!1),o&&(delete c[t],i.silent?u._silent[t]=!0:i.changes[t]=!0);var a=r.last(u._opSetQueue);a[t]=n._mergeWithPrevious(a[t]),u._rebuildEstimatedDataForKey(t),o?(u.changed[t]=u.attributes[t],i.silent||(u._pending[t]=!0)):(delete u.changed[t],delete u._pending[t])}),i.silent||this.change(i),this},
setACL: function (e,t){return this.set("ACL",e,t)},
toJSON: function (){var t=this._toFullJSON();return e._arrayEach(["__type","className"],function(e){delete t[e]}),t},
trigger: function (e){var r,i,s,o,a,u,c;if(!(s=this._callbacks))return this;for(u=s.all,e=e.split(t),c=n.call(arguments,1),r=e.shift();r;){if(i=s[r])for(o=i.tail;(i=i.next)!==o;)i.callback.apply(i.context||this,c);if(i=u)for(o=i.tail,a=[r].concat(c);(i=i.next)!==o;)i.callback.apply(i.context||this,a);r=e.shift()}return this},
unbind: function (e,n,r){var i,s,o,a,u,c;if(s=this._callbacks){if(!(e||n||r))return delete this._callbacks,this;for(e=e?e.split(t):_.keys(s),i=e.shift();i;)if(o=s[i],delete s[i],o&&(n||r)){for(a=o.tail,o=o.next;o!==a;)u=o.callback,c=o.context,(n&&u!==n||r&&c!==r)&&this.on(i,u,c),o=o.next;i=e.shift()}return this}},
unset: function (e,t){return t=t||{},t.unset=!0,this.set(e,null,t)},
validate: function (t,n){return!r.has(t,"ACL")||t.ACL instanceof e.ACL?!1:new i(i.OTHER_CAUSE,"ACL must be a AV.ACL.")}
}
[object Object] {
beizhu: "身体不适",
dateleaver: [object Date] { ... },
values: 3
}