File tree Expand file tree Collapse file tree 5 files changed +34
-0
lines changed Expand file tree Collapse file tree 5 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -269,6 +269,8 @@ declare module Backendless {
269269
270270 function describe ( model : string | Object | Function ) : Promise < Object > ;
271271
272+ function getTableNameById ( tableId : string ) : Promise < string > ;
273+
272274 function mapTableToClass ( tableName : string , clientClass : Function ) : void ;
273275 function mapTableToClass ( clientClass : Function ) : void ;
274276 }
Original file line number Diff line number Diff line change @@ -61,6 +61,12 @@ export default class Data {
6161 } )
6262 }
6363
64+ async getTableNameById ( tableId ) {
65+ return this . app . request . get ( {
66+ url : this . app . urls . dataTableNameById ( tableId ) ,
67+ } )
68+ }
69+
6470 mapTableToClass ( tableName , clientClass ) {
6571 if ( typeof tableName === 'function' ) {
6672 clientClass = tableName
Original file line number Diff line number Diff line change @@ -157,6 +157,10 @@ export default class Urls {
157157 return `${ this . dataTable ( tableName ) } /permissions/${ permissionType } /${ objectId } `
158158 }
159159
160+ dataTableNameById ( tableId ) {
161+ return `${ this . data ( ) } /${ tableId } /table-name`
162+ }
163+
160164 transactions ( ) {
161165 return `${ this . root ( ) } /transaction/unit-of-work`
162166 }
Original file line number Diff line number Diff line change @@ -562,6 +562,8 @@ function testPersistence() {
562562 promiseObject = Backendless . Data . describe ( 'str' ) ;
563563 promiseObject = Backendless . Data . describe ( { } ) ;
564564
565+ promiseObject = Backendless . Data . getTableNameById ( 'str' ) ;
566+
565567 Backendless . Data . mapTableToClass ( Model ) ;
566568 Backendless . Data . mapTableToClass ( 'ClassName' , Model ) ;
567569}
Original file line number Diff line number Diff line change @@ -188,4 +188,24 @@ describe('<Data> Store', function() {
188188 } )
189189 } )
190190
191+ describe ( 'Table Name By Id' , ( ) => {
192+ it ( 'table id from string' , async ( ) => {
193+ const fakeResult = 'tableName'
194+ const tableId = '123'
195+
196+ const req1 = prepareMockRequest ( fakeResult )
197+
198+ const result = await Backendless . Data . getTableNameById ( tableId )
199+
200+ expect ( req1 ) . to . deep . include ( {
201+ method : 'GET' ,
202+ path : `${ APP_PATH } /data/${ tableId } /table-name` ,
203+ headers : { } ,
204+ body : undefined
205+ } )
206+
207+ expect ( result ) . to . be . eql ( fakeResult )
208+ } )
209+ } )
210+
191211} )
You can’t perform that action at this time.
0 commit comments