diff --git a/lib/table.js b/lib/table.js index f7f2f888..5fd6c6fc 100644 --- a/lib/table.js +++ b/lib/table.js @@ -88,11 +88,7 @@ var Table = Class.extend({ } var requestData; if (isCreatingMultipleRecords) { - requestData = { - records: recordsData.map(function (fields) { - return {fields: fields}; - }), - }; + requestData = {records: recordsData}; } else { requestData = {fields: recordsData}; } diff --git a/test/create.test.js b/test/create.test.js index f368007a..fd71921e 100644 --- a/test/create.test.js +++ b/test/create.test.js @@ -66,7 +66,9 @@ describe('record creation', function () { return airtable .base('app123') .table('Table') - .create([{foo: 'boo'}]) + .create([{ + fields: {foo: 'boo'} + }]) .then(function (createdRecords) { expect(createdRecords).toHaveLength(1); expect(createdRecords[0].id).toBe('rec0'); @@ -79,8 +81,8 @@ describe('record creation', function () { .base('app123') .table('Table') .create([ - {foo: 'boo'}, - {bar: 'yar'}, + {fields: {foo: 'boo'}}, + {fields: {bar: 'yar'}}, ]) .then(function (createdRecords) { expect(createdRecords).toHaveLength(2); @@ -96,8 +98,8 @@ describe('record creation', function () { .base('app123') .table('Table') .create([ - {foo: 'boo'}, - {bar: 'yar'}, + {fields: {foo: 'boo'}}, + {fields: {bar: 'yar'}}, ], function (err, createdRecords) { expect(err).toBeNull(); expect(createdRecords).toHaveLength(2); @@ -114,8 +116,8 @@ describe('record creation', function () { .base('app123') .table('Table') .create([ - {foo: 'boo'}, - {bar: 'yar'}, + {fields: {foo: 'boo'}}, + {fields: {bar: 'yar'}}, ], {typecast: true}) .then(function (createdRecords) { expect(createdRecords).toHaveLength(2);