diff --git a/api/service/dbService.js b/api/service/dbService.js index 6962786..77ba3bd 100644 --- a/api/service/dbService.js +++ b/api/service/dbService.js @@ -145,27 +145,32 @@ var Meeting = { }, updateMeeting: function (meetings) { //mid, title, note, start_time, end_time, rid - return this.getMeetingByMid(meetings.mid).then(function (meeting) { - if (!meeting) { + //console.log("[updateMeeting] meetings: "+JSON.stringify(meetings)) + return this.getMeetingByMid(meetings.mid).then(function(meeting){ + if(!meeting){ return Promise.resolve(false); } var meetingFolder = AV.Object.createWithoutData('Meeting', meeting.get('objectId')); - meetingFolder.set('title', meetings.title); - meetingFolder.set('note', meetings.note); + //var meetingFolder = AV.Object.createWithoutData('Meeting', meeting.objectId); + meetingFolder.set('title',meetings.title); + meetingFolder.set('note',meetings.note); meetingFolder.set('start_time', meetings.start_time); meetingFolder.set('end_time', meetings.end_time); meetingFolder.set('rid', meetings.rid); return meetingFolder.save().then( - ()=>Promise.resolve(true) - , ()=>Promise.resolve(false) + ()=>Promise.resolve(true) + ,(error)=>{ + console.log("[updateMeeting ]error: "+JSON.stringify(error)); + return Promise.resolve(false) + } ); }); }, getMeetings: function (start, limit) { var query = new AV.Query('Meeting'); - query.skip(start); query.limit(limit); + query.skip(start); return query.find(); }, getMeetingsByTime: function (start_time, end_time) { diff --git a/test/api/service/dbServiceMeetingTest.js b/test/api/service/dbServiceMeetingTest.js index 7477831..559e920 100644 --- a/test/api/service/dbServiceMeetingTest.js +++ b/test/api/service/dbServiceMeetingTest.js @@ -35,7 +35,7 @@ describe('Meeting', function(){ i); } //console.log(JSON.stringify(meetings)) - + var uMeetings = []; describe('create', function(){ it('createMeeting', function(){ //var result = Promise.resolve(true); @@ -55,6 +55,8 @@ describe('Meeting', function(){ promiseList.push(Meeting.createMeeting(meeting.title, meeting.note, meeting.start_time, meeting.end_time, meeting.rid).then(function(res){ //console.log("[createMeeting] "+res.get('title')); + uMeetings.push(res); + //console.log("[createMeeting] "+JSON.stringify(res)); expect(res).to.be.ok; })); }); @@ -68,12 +70,13 @@ describe('Meeting', function(){ }) }) - var uMeetings; + describe('get', function(){ it('getMeetings', function(){ return Meeting.getMeetings(0, meetings.length).then(function(data){ - uMeetings = data; + //console.log("[getMeetings] data: "+JSON.stringify(data)) + //uMeetings = data; //data.forEach(function(meeting){ // meetings.forEach(function(item){ // if(item.rid==meeting.get('rid')){