The Search feature in mongodb not working?

My ApiFeatures is work fine without the search feature when I add the keyword to the query the response is always empty array

class ApiFeatures {
  constructor(mongooseQuery, queryStr) {
    this.mongooseQuery = mongooseQuery;
    this.queryStr = queryStr;
  }

  filter() {
    const queryObj = { ...this.queryStr };
    const excludesFields = ['page', 'sort', 'limit', 'fields'];
    excludesFields.forEach(field => delete queryObj[field]);

    let queryStr = JSON.stringify(queryObj);
    queryStr = queryStr.replace(/b(gte|gt|lte|lt)b/g, match => `$${match}`);

    this.mongooseQuery = this.mongooseQuery.find(JSON.parse(queryStr));

    return this;
  }

  sort() {
    if (this.queryStr.sort) {
      const sortBy = this.queryStr.sort.split(',').join(' ');
      this.mongooseQuery = this.mongooseQuery.sort(sortBy);
    } else {
      this.mongooseQuery = this.mongooseQuery.sort('-sold');
    }
    return this;
  }

  limitFields() {
    if (this.queryStr.fields) {
      const fields = this.queryStr.fields.split(',').join(' ');
      this.mongooseQuery = this.mongooseQuery.select(fields);
    } else {
      this.mongooseQuery = this.mongooseQuery.select('-__v');
    }
    return this;
  }

  search() {
    if (this.queryStr.keyword) {
      const query = {};
      query.$or = [
        {
          title: {
            $regex: this.queryStr.keyword,
            $options: 'i',
          },
        },
        {
          description: {
            $regex: this.queryStr.keyword,
            $options: 'i',
          },
        },
      ];
      console.log(query);
      this.mongooseQuery = this.mongooseQuery.find(query);
    }
    return this;
  }

  paginate() {
    const page = this.queryStr.page * 1 || 1;
    const limit = this.queryStr.limit * 1 || 50;
    const skip = (page - 1) * limit;

    this.mongooseQuery = this.mongooseQuery.skip(skip).limit(limit);

    return this;
  }
}

module.exports = ApiFeatures;


I think the problem is in the mongooseQuery.find because I call it twice the first with the Filter and the second with the Search I am not sure! , I tried but I didn’t find a solution.

How To Give an MUI Modal Component an Exit Animation that’s Different from the Opening Animation?

Trying to give an MUI modal another animation on close.

I have tried 2 ways of trying to achieve a closing animation for my modal.

Both of them do the correct opening animation, but I can’t seem to get the latter closing animation to happen (onClose)…

My initial attempt:

Container:

import React, { useState, useEffect } from "react";
import { useSpring } from 'react-spring';

const [showWebAndAppActivityModal, setShowWebAndAppActivityModal] = useState(false);

const openWebAndAppActivityModal = () => setShowWebAndAppActivityModal(true);

const closeWebAndAppActivityModal = () => setShowWebAndAppActivityModal(false);

const animationOpen = useSpring({
  transform: showWebAndAppActivityModal ? `scale(1)` : `scale(0.85)`,
  config: {
    duration: 175,
    easing: t => t < 0.5 ? 2*t*t : -1+(4-2*t)*t
  }
});

const animationClose = useSpring({
  transform: showWebAndAppActivityModal ? `scale(0.85)` : `scale(1)`,
  config: {
    duration: 300,
    easing: t => t < 0.5 ? 2*t*t : -1+(4-2*t)*t
  }
});

return(
    <>
        <ExpressChooseYourSettingsComponent
            openWebAndAppActivityModal={openWebAndAppActivityModal}
            closeWebAndAppActivityModal={closeWebAndAppActivityModal}
            showWebAndAppActivityModal={showWebAndAppActivityModal}
            animationOpen={animationOpen}
            animationClose={animationClose}
        />
    </>
 );

Component:

showWebAndAppActivityModal,
closeWebAndAppActivityModal,
openWebAndAppActivityModal,
animationOpen,
animationClose,

<Modal
  open={showWebAndAppActivityModal}
  onClose={closeWebAndAppActivityModal}
  closeAfterTransition
  className='modal-ecys'
>
  <animated.div style={showWebAndAppActivityModal ? animationOpen : animationClose}>  
    <Box>
      (divs)
    </Box>
  </animated.div>
</Modal>

Syntax from the MUI Modal docs

Container:

import { useSpring } from 'react-spring';
import PropTypes from 'prop-types';
import React, { useState, useEffect } from "react";

const [showWebAndAppActivityModal, setShowWebAndAppActivityModal] = useState(false);

// Handle Modals

    const openWebAndAppActivityModal = () => setShowWebAndAppActivityModal(true);

    const closeWebAndAppActivityModal = () => setShowWebAndAppActivityModal(false);

    const Fade = React.forwardRef(function Fade(props, ref) {
        const {
            children,
            in: open,
            onClick,
            onEnter,
            onExited,
            ownerState,
            ...other
        } = props;
        const style = useSpring({
            from: { scale: 0.85 },
            to: { scale: open ? 1 : 0.85 },
            config: {
                duration: 175,
                easing: t => t < 0.5 ? 2*t*t : -1+(4-2*t)*t,
            },
            onStart: () => {
                if (open && onEnter) {
                    onEnter(null, true);
                }
            },
            onRest: () => {
                if (!open && onExited) {
                    onExited(null, true);
                }
            },
        });

        return (
            <animated.div ref={ref} style={style} {...other}>
              {React.cloneElement(children, { onClick })}
            </animated.div>
        );
    });

    Fade.propTypes = {
        children: PropTypes.element.isRequired,
        in: PropTypes.bool,
        onClick: PropTypes.any,
        onEnter: PropTypes.func,
        onExited: PropTypes.func,
        ownerState: PropTypes.any,
    };

return(
    <>
        <ExpressChooseYourSettingsComponent
            openWebAndAppActivityModal={openWebAndAppActivityModal}
            Fade={Fade}
        />
    </>
 );

Component:

import { Modal, Box } from '@mui/material';
import Backdrop from '@mui/material/Backdrop';

showWebAndAppActivityModal,
Fade,

<Modal
  open={showWebAndAppActivityModal}
  onClose={closeWebAndAppActivityModal}
  closeAfterTransition
  slots={{ backdrop: Backdrop }}
  slotProps={{
    backdrop: {
      TransitionComponent: Fade,
    },
  }}
  className='modal-ecys'
>
  <Fade in={open}>
    <Box>
     (divs)
    </Box>
  </Fade>
</Modal>

Was expecting a simply open animation on open and the close animation on close

Any help greatly appreciated.

Cannot call state from redux in react-pdf component

i am trying to firgure out how to use this react-pdf lib in my project. At first I tried to render the state directly from redux store into a react-pdf component and it didn’t worked.

It shows the Error:

could not find react-redux context value; please ensure the component is wrapped in a <Provider>

I have many other components which have used the state from redux and none of them have this problem until I tried to render a component from react-pdf within and .

Here is a part of my code:

const ConfigurationListPdf = (props)=> {
    const mech = useSelector(mechConfig);
    return(
            <>
                <Document>
                    <Page size="A4" style={styles.page}>
                        <View style={styles.section}>
                            <Text>
                                {props.elem}
                            </Text>
                        </View>
                    </Page>
                </Document>
            </>
        )
}

export default function InfoBoard(){
    const styles = StyleSheet.create({
        page: {
            flexDirection: 'row',
        },
        section: {
            margin: 10,
            padding: 10,
            flexGrow: 1
        }
    });

// Create Document Component
    return(
        <>
            <CntrInfoBoard>
                <InnerBoard>
                    <TitelDiv>
                    <Typography variant="h5" sx{{color:'white',fontWeight:900}}>Summary</Typography>
                    </TitelDiv>
                    <CntrInfoDetails>
                        <NodeTable/>
                    </CntrInfoDetails>
                    <Terms>
                        <p>
                            xxx
                        </p>
                    </Terms>
                    <PDFViewer>
                        <ConfigurationListPdf />
                    </PDFViewer>
                    <CntrSaveBtn>
                        <BtnSave>Configuration save</BtnSave>
                        <BtnOther>Sign up to finish</BtnOther>
                        <BtnOther onClick={savePdfHandler}>
                            {/*Save to PDF*/}
                            <PDFDownloadLinkStyled
                                document={<ConfigurationListPdf/>}
                                fileName="example.pdf"
                            >
                                Download PDF
                            </PDFDownloadLinkStyled>
                        </BtnOther>
                    </CntrSaveBtn>
                </InnerBoard>
            </CntrInfoBoard>
        </>
    )
}

Sorry if there is a problem with the code formatting.

As long as I add a useSelector or useDispatch it shows the error.

This is weird because the has already been wrapped in my index.js:

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
    <React.StrictMode>
        <Provider store={store}>
            <App/>
        </Provider>
    </React.StrictMode>
);

I thought my redux store has a problem so I tried to call state and reducers in other components without react-pdf and turns out that’s not the case. They work fine.

Any idea?

Issue with Generating Random Values for Feature Properties in Google Earth Engine

I’m encountering an issue while trying to generate random values for feature properties in Google Earth Engine. I have a FeatureCollection containing points representing cities, and I want to add a property called ‘year’ to each feature with random values for each year (2015, 2016, and 2017) and for each band (b1, b2, b3, and b4).

Here’s the code I’ve tried:

// Create a FeatureCollection
var fc = ee.FeatureCollection([
  ee.Feature(ee.Geometry.Point([-74.006, 40.712]), {name: 'New York'}),
  ee.Feature(ee.Geometry.Point([-118.243, 34.052]), {name: 'Los Angeles'}),
  ee.Feature(ee.Geometry.Point([-95.369, 29.760]), {name: 'Houston'})
]);

// Define a function to add a property 'year' to each feature with random values
var addYearProperty = function(feature) {
  var bands = ['b1', 'b2', 'b3', 'b4'];
  var year_random = function() {
    // Generate random values for each band
    var band_values = function() {
      var band_values_dict = {};
      bands.map(function(band) {
        band_values_dict[band] = Math.random() * 10;
      });
      return band_values_dict; 
    };
    var randomValues = band_values();
    // Create a dictionary with bands as keys and their respective random values
    var year = randomValues;
    return year;
  };
  var year2015 = year_random();
  var year2016 = year_random();
  var year2017 = year_random();

  // Set the 'year' property with the generated random values for each year for this feature
  return feature.set('year', {'2015': year2015, '2016': year2016, '2017': year2017});
};

// Use map to apply the function to each feature in the FeatureCollection
var modifiedFC = fc.map(addYearProperty);

// Print the modified FeatureCollection
print(modifiedFC);

However, the resulting FeatureCollection shows that the same random values are assigned to all features for each year, which is not the expected behavior. I’ve tried to modify the code to generate unique random values for each feature and year, but I haven’t been successful. Any suggestions on how to fix this issue would be greatly appreciated! Thank you!

Google Consent-Mode: “Region-based-Consent” always on granted, although everything is on denied?

I come from Germany and my English is only as good as Google Translator ๐Ÿ™‚

I’ve been reading here for years and am now asking my first question:

I integrated Google Consent Mode correctly according to Google instructions (it’s not too difficult) and tested it in the tag assistant. It responds correctly to the user settings in the following columns and changes to granted or denied accordingly:

  • On-page Default
  • On-page Update
  • Current State

The problem is the preceding Region-based-Consent column. This always stays on granted, no matter what I do. (see attached image) Although I didn’t make any region-specific settings in the code.

Tag assistant Screenshot

What does that mean now???

According to the attached screenshot, will the user data continue to be processed for the processing purposes (ad_storage, analytics_storage, ad_user_data, ad_personalization) even though all other columns are set to denied??? Or is everything correct? Why doesn’t the Region-based-consent column change? I stand on the hose. My question actually only revolves around this unfortunately unresponsive column…

Thanks in advance and greetings from Germany!

Example-Code for information (nothing special):

<head>

<!-- Google Consent Mode v2 Default -->
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}

gtag('consent', 'default', {
  'ad_storage': 'denied',
  'ad_user_data': 'denied',
  'ad_personalization': 'denied',
  'analytics_storage': 'denied',
  'wait_for_update': 1000
});
gtag('set', 'ads_data_redaction', true);


<!-- Here are the typical GOOGLE TAGS for analytics etc., I'll save those -->


<!-- Google Consent Mode v2 Update Function -->
function consent_granted_ad_storage(){
gtag('consent', 'update', {
'ad_storage': 'granted'
});
}

function consent_granted_ad_user_data(){
gtag('consent', 'update', {
'ad_user_data': 'granted'
});
}

function consent_granted_ad_personalization(){
gtag('consent', 'update', {
'ad_personalization': 'granted'
});
}

function consent_granted_analytics_storage(){
gtag('consent', 'update', {
'analytics_storage': 'granted'
});
}

function consent_denied_ad_storage(){
gtag('consent', 'update', {
'ad_storage': 'denied'
});
}

function consent_denied_ad_user_data(){
gtag('consent', 'update', {
'ad_user_data': 'denied'
});
}

function consent_denied_ad_personalization(){
gtag('consent', 'update', {
'ad_personalization': 'denied'
});
}

function consent_denied_analytics_storage(){
gtag('consent', 'update', {
'analytics_storage': 'denied'
});
}
</script>
</head>

<body>
<!--  Example of calling the functions -->
<button onclick="consent_denied_analytics_storage()">No</button>
</body>

Ich hope sombody can help me and had the same problem.

aws amplify admin query /listGroups not returning NextToken

When I try to use amplify admin query to get an array of all the user pool groups the max I can get is 60 but the response never has a nextToken in it self even when I change the limit to 25 or 50
(I have 61 user groups in userpool), I have tried a different admin query listUsers and that one correctly returns a NextToken. This is how the admin query called from cognitoActions.js file

async function listGroups(Limit, PaginationToken) {
  const params = {
    UserPoolId: userPoolId,
    ...(Limit && { Limit }),
    ...(PaginationToken && { PaginationToken }),
  };

  console.log('Attempting to list groups');

  try {
    const result = await cognitoIdentityServiceProvider
      .listGroups(params)
      .promise();

    // Rename to NextToken for consistency with other Cognito APIs
    result.NextToken = result.PaginationToken;
    delete result.PaginationToken;

    return result;
  } catch (err) {
    console.log(err);
    throw err;
  }
}

What I expect to happen here it to get 50 groups from the first run with a nextToken and finaly 11 from the next one with a nextToken that is undefined. It worked correctly with listUsers so I don’t understand why listGroups doesn’t work.
The solution I’ve tried: https://github.com/aws-amplify/amplify-cli/issues/8362

 let nextToken;
      const results = [];
      const apiName = 'AdminQueries';
      const path = '/listGroups';
      do {
        const myInit = {
          queryStringParameters: {
            limit: 50,
            token: nextToken,
          },
          headers: {
            'Content-Type': 'application/json',
            Authorization: `${(await Auth.currentSession())
              .getAccessToken()
              .getJwtToken()}`,
          },
        };
        const response = await API.get(apiName, path, myInit);
        const { NextToken, Groups } = response;
        nextToken = NextToken;
        results.push(...Groups);
      } while (nextToken);
      console.log(results);

      return results;

How to display decorated text with an icon in Gmail Add-on?

Earlier I used the below code for displaying a decorated text in Gmail Add-on but the same code is now showing only text without icon. Is there any new method or another way to achieve same functionality?

var card = CardService.newCardBuilder();
var section = CardService.newCardSection(); // Create a card section
var htmlContent = 'Add Card';
var decoratedText = CardService.newDecoratedText()
  .setText(htmlContent)
  .setOnClickAction(CardService.newAction().setFunctionName("showFirstCard"))
  .setIconUrl("https://i.imgur.com/x5Mh3vL.png");

section.addWidget(decoratedText);

card.addSection(section);

return card.build();

Can’t update innerHTML on “instagram.com/direct” through javascript

I am making an extension for google chrome to allow me to quickly type emojies, for example if the word ‘heart’ is typed in betwen two colons, the extension will automatically change it into ❤️.
It works on certain websites (it works here on stackoverflow) but it wont work on IG, specifically in IG direct messages (which was the original purpose of the extension).
I have tried just changing it directly from the console but it isnt changing. attempting to change message through console

The code is available here:
github repo
There are definitely other issues with the project, and if you notice any please let me know.

I have tried to eddit innerHTML, innerText and other properties that seemed relevant but that changed nothing.
I tried changing it directly from the console, but as is shown in the picture above it has no effect.

Unexpected Gateway Response: 515 – Could not decrypt tokenised data (Apple Pay)

I followed this tutorial https://developer.globalpay.com/ecommerce/applepay#api

but when there is a token from apple pay and post to global payment, an error is returned
“Gateway Response: 515 – Could not decrypt tokenised data”

this is a token from apple pay
“{“version”:”EC_v1″,”data”:”tABE3r5bDyQnbs3xbFd1ELqrLkK1Nod2Q+fAo4ir8BbJ2dF2pMxYxiMfO7bM2WzGkDjMbeHQYNgduG2lCRtygN0LrWYm8N1/6PRRzqx3woURKMPbZCTO2BcZe3M+wSe9d5LTTEYW+JpPmkNT9Tdo5O50bP5fDNRLVztfWIvxv1BvLo/byw6GadlkjTfjWKBNz5Wd5+TiqdA/qZQkIxyj+gTSuJ2/bWVdEPuQrMbVe9NwB9+3wf/KYZyRltYn52uI0M+5PNS3UpT4yLKrNrtvNdeiS0mRitZd2elBDzgGcTwRxF+zJzWPMXc6YA1+thynbcs81hDUyFYFpCAPDO1b4ssZOzbQ9ziRRDE9IchwqlOXJ8PjYIUc9Hn8ZLJmvxRQExhiEvBxRo3ZixEfSuCwus6aSdJykXKPH4UUCJIot90=”,”header”:{“publicKeyHash”:”zgtVsxrGQ4Sfi7g2xJkLh9vRxnpA5903dDv58HFgHOk=”,”ephemeralPublicKey”:”MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEaQwyNCNknVYQO9wrDiPCB96sSWea1D9NQ6VhHm2rUHlp5Z6BodME/rL6wE1sOe/f8cbXsn8yTOldJIvDx9NrMg==”,”transactionId”:”b9a547ad7aab9a7698d04c9a7f34b3835d1571843642477db1d303b1b5881e17″}}”

post token to global payment and response success

Getting Unhandled Runtime Error of “self is not defined”

In my Next js app,

Getting Unhandled Runtime Error
Error: self is not defined

community/[title]/page.js:

"use server";
import Subpage from './subpage.js';

export default async function page({ params }) {
    return (
        <div>
            <Subpage params={params} /> //Client side component with hooks
        </div>
    )
}

If i add "use client"; instead of "use server";
It’s working, but i want to fetch some data in page.js with server-side action

Also i am not able to make Subpage client side because i want to use hooks too and my code is also perfectly working along with “self is not defined” error.

In subpage i am using a lot things with CKEditor too

I want solution how to remove “self error” without removing "use server"; and without making subpage serverside.

metchod chaining in javascript OOP classes [closed]

Hello I am trying to learn OOP in javascript and i have problem. I don’t know how write implementation usinn metchod chaining and static methods. I would like to implement a class that will contain methods that will check the key values โ€‹โ€‹that are passed to my class.

this is example of my code

export class Validation {
  constructor(input) {
    this.input = input;
  }
  
  isNumberValidation() {
    const isNumberCondition = typeof this.input === "number";
    if (!isNumberCondition) throw new Error("input must be a number");
    return this;
  }

  isGreaterThanZeroValidation() {
    const isGreaterThanZeroCondition = this.input > 0;
    if (!isGreaterThanZeroCondition)
      throw new Error("input must be greater than zero");
    return this;
  }

const nike ={
    name: "nike",
    price: 199, 
    category: ["sport", "kids", "football"]
}

class ShopShelf{
    constructor(productObj){
        
        const {name, price, category } = productObj

        new Validator(price).isNumber().isGreatherThanZeroValidation()
        new Validator(name).isStringValidation();
        new Validator(category).isArray();

        
    }
}

and i want to implement this Validator in the way that allows me to not use “new” operator

I’ve tried to use static but dosn’t work

API Get data and Send Email in sap ui5 app

I need to SOAP API get data for click button in sap ui5 and these data send any I given email .
IT is my problem.

Please given me correct steps and code..

I try these code ..
on_Send_Email_Press : function () {
var that = this;

            // API call to fetch data
            jQuery.ajax({
                url: "https://jsonplaceholder.typicode.com/posts",
                method: "GET",
                success: function (data) {
                    console.log(data);

                    // Send data via email
                    that.sendDataByEmail(data);
                },
                error: function (err) {
                    console.error("Error: ", err);
                    // Show MessageBox for error
                    MessageBox.error("Error fetching data from API");
                }

            });

            this.sendEmail()
                .then(function (result) {
                    console.log("Email is sent", result);
                    MessageBox.success("Email sent successfully!");
                })
                .catch(function (error) {
                    console.error("An error occurred", error.message);
                    MessageBox.error("Error sending email. Please try again later.");
                });
        }

FIRESTORE currentUser in getAuth() has value, but getAuth().currentUser is null

I’m developing with React and Firebase.
I was working on creating a feature where the user’s name and photo are displayed in the <NavBar /> component upon logging in.
I learned that I can use onAuthStateChanged() for this, but I was curious, so I have a question.

const auth = getAuth();
console.log(auth); 
console.log(auth.currentUser); 

First, I logged in with Google using signInWithPopup().
I assigned the value returned by getAuth() to a constant called auth.
console.log(auth) prints an object containing information about the currently logged-in user, including currentUser.

const obj = { a: 1, b: 2 };
console.log(obj); // { a: 1, b: 2 }
console.log(obj.a); // 1

I thought console.log(auth.currentUser) would work similarly to the above code, but it prints null.
I expected it to show the information of the currently logged-in user since console.log(auth) shows a non-null currentUser. I’m confused why auth.currentUser is null when console.log(auth) shows a value for currentUser.

Does anyone know why this is happening?
I couldn’t find any other answers besides using onAuthStateChanged(), so I’m asking again.

Other values like auth.config are showing up fine.

How to fix : PothosSchemaError [GraphQLError]: Ref ObjectRef has not been implemented

PothosSchemaError [GraphQLError]: Ref ObjectRef has not been implemented.

if I run pnpm dev and get this error, how do I fix it?

PothosSchemaError [GraphQLError]: Ref ObjectRef has not been implemented
at constructor (/home/lakshitha/Projects/bisbig/bisbig-api/node_modules/.pnpm/@[email protected][email protected]/node_modules/@pothos/core/src/errors.ts:7:5)
at constructor (/home/lakshitha/Projects/bisbig/bisbig-api/node_modules/.pnpm/@[email protected][email protected]/node_modules/@pothos/core/src/errors.ts:14:5)
at getTypeConfig (/home/lakshitha/Projects/bisbig/bisbig-api/node_modules/.pnpm/@[email protected][email protected]/node_modules/@pothos/core/src/config-store.ts:289:13)
at getType (/home/lakshitha/Projects/bisbig/bisbig-api/node_modules/.pnpm/@[email protected][email protected]/node_modules/@pothos/core/src/build-cache.ts:444:41)
at getOutputType (/home/lakshitha/Projects/bisbig/bisbig-api/node_modules/.pnpm/@[email protected][email protected]/node_modules/@pothos/core/src/build-cache.ts:458:23)
at buildOutputTypeParam (/home/lakshitha/Projects/bisbig/bisbig-api/node_modules/.pnpm/@[email protected][email protected]/node_modules/@pothos/core/src/build-cache.ts:283:36)
at buildOutputTypeParam (/home/lakshitha/Projects/bisbig/bisbig-api/node_modules/.pnpm/@[email protected][email protected]/node_modules/@pothos/core/src/build-cache.ts:273:37)
at buildFields (/home/lakshitha/Projects/bisbig/bisbig-api/node_modules/.pnpm/@[email protected][email protected]/node_modules/@pothos/core/src/build-cache.ts:345:20)
at getRootFields (/home/lakshitha/Projects/bisbig/bisbig-api/node_modules/.pnpm/@[email protected][email protected]/node_modules/@pothos/core/src/build-cache.ts:416:17)
at getFields (/home/lakshitha/Projects/bisbig/bisbig-api/node_modules/.pnpm/@[email protected][email protected]/node_modules/@pothos/core/src/build-cache.ts:422:21) {
path: undefined,
locations: undefined,
extensions: [Object: null prototype] {}
}

Node.js v18.17.1


`timeLogs.ts` code


import { schemaBuilder } from '@api/schemaBuilder';
import { GraphQLError } from 'graphql/error';
import { db } from '@api/drizzle';
import { and, eq } from 'drizzle-orm';
import { TimeLogs } from '@modules/projectManagement/types';
import { timeLogs } from '@modules/projectManagement/db/timeLogs';

schemaBuilder.queryField('timeLogs', (t) =>
  t.field({
    type: [TimeLogs],
    nullable: true,
    args: {
      organisationId: t.arg.string({ required: true }),
    },

    async resolve(root, { organisationId }) {
      try {
        return await db.query.timeLogs.findMany({
          where: and(eq(timeLogs.projectOrganisationId, organisationId)),
        });
      } catch (error) {
        throw new GraphQLError('data-fetch-error');
      }
    },
  }),
);

How to use CopyWebpackPlugin to copy static assets

I’m using this configuration pattern:

new CopyWebpackPlugin({
    patterns: [{
        from: `src/assets/static/**/*`,
        to: 'dist',
    }]
})

But this results to

  • from -> src/assets/static/images
  • to-> dist/src/assets/static/images

Expected Output:

  • from -> src/assets/static/images
  • to-> dist/assets/static/images

Can anyone point out what am I doing wrong?