SwapIt / utils / database.mjs
database.mjs
Raw
import {google} from 'googleapis';

async function db(){
    const auth = new google.auth.GoogleAuth({
        keyFile: "./utils/credentials.json",
        scopes: "https://www.googleapis.com/auth/spreadsheets",
    });
    
    const client = await auth.getClient();
    
    //instance of google sheets api
    const googleSheets = google.sheets({version : 'v4' , auth : client});
    const spreadsheetId = "1PmFf14eqIvoLIrYxT48hL1ixfeeCXgbo1GQMgiSS3zg";

        
    
    //return functions and operations on data base
    return {googleSheets,spreadsheetId,auth};
}

export const schema =  await db();



// const d =async ()=>{
//     return await db();   
// }
// console.log(d.Users_Detail);

// export default data();