Uno-Dan

DBMagic Driver

Feb 27th, 2021
930
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. jQuery( document ).ready( () => {
  2.  
  3.   const setup1 = () => {
  4.     new DBMagic( 'MyDB2', true )
  5.     .table( 'users' )
  6.     .then( tbl => {
  7.       return tbl.add( [
  8.         { id:1, fName: 'Joe', lName: 'Smith', group: 2 },
  9.         { id:2, fName: 'Jane', lName: 'Peterson', group: 3 },
  10.         { id:3, fName: 'Billy', lName: 'Robertson', group: 2 },
  11.         { id:4, fName: 'Mark', lName: 'White', group: 1 }
  12.       ] );    
  13.     } )
  14.     .then( tbl => { return tbl.delete( [ {id: 1}, {id: 3} ] ); } )
  15.     .then( tbl => { return tbl.get(); } )
  16.     .then( results => { log('Results:', results ); } );
  17.   };
  18.   setup1();
  19.  
  20.   const setup2 = async () => {
  21.    
  22.     let db1 = new DBMagic( 'MyDB1', true );
  23.     let tbl = await db1.table( 'users' );
  24.    
  25.     tbl.add( { id: 1, fName: 'Joe', lName: 'Doe', group: 3 } );
  26.    
  27.     tbl.add( [
  28.       { id: 2, fName: 'Jane', lName: 'Doe', group: 1 },
  29.       { id: 3, fName: 'Peter', lName: 'Parker', group: 2 }
  30.     ] );
  31.     log('Test 1 source data:', await tbl.get() );
  32.    
  33.     tbl.update( [
  34.       { id: 2, fName: 'Mary', lName: 'Smith', group: 3 },
  35.       { id: 3, fName: 'Mad', lName: 'Max', group: 1 }
  36.     ] );
  37.    
  38.     await tbl.delete( [ {id: 1}, {id: 3} ] );
  39.    
  40.     log('Test 1 updated data:', await tbl.get() );
  41.   };
  42.   setup2();  
  43.  
  44. } );
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×