> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: and(query: PublicPlansQueryBuilder) # Method package: wixPricingPlansBackend # Method menu location: wixPricingPlansBackend --> PublicPlansQueryBuilder --> and # Method Link: https://dev.wix.com/docs/velo/apis/wix-pricing-plans-backend/public-plans-query-builder/and.md # Method Description: Adds an `and` condition to the query. The `and()` function adds an `and` condition to a `PublicPlansQueryBuilder`. A query with an `and` returns all the items that match the query as defined up to the `and` function. Note that when chaining multiple `PublicPlansQueryBuilder` functions to a query an `and` condition is assumed. In such cases, you do not need to add a call to the `and()` function. For example, this query returns results where the plan was created during a certain date range **and** the plan's slug starts with "gold" (such as `gold`, `gold-vip`, `gold-trial`). ```javascript wixPricingPlansBackend.queryPublicPlans() .between("_createdDate", specificDate, now) .startsWith("slug", "gold"); ``` The `and()` function is needed when performing compound queries. For example, the final query, `typeAndDateQuery`, in this set of queries returns results where a plan is created after a certain date, **and** the plan is either a "gold" or a "silver" membership plan, as defined in the plan's slug. ```javascript const slugPlanQuery = wixPricingPlansBackend.queryPublicPlans() .startsWith("slug", "silver") .or( wixPricingPlansBackend.plans.queryPublicPlans() .startsWith("slug", "gold") ); const datePlanQuery = wixPricingPlansBackend.queryPublicPlans() .between("_createdDate", date, now); ); const typeAndDateQuery = slugPlanQuery.and(datePlanQuery); ``` The 'and()' function is designed to work with 2 or more queries or filters. If you use it on its own, it will return all the items in a collection. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Add an `and` filter to a query ```javascript const newQuery = query1.and(query2); ``` ## Create a compound query, add an `and` filter, and run it ```javascript import wixPricingPlansBackend from 'wix-pricing-plans-backend'; // ... const now = new Date(); const date = new Date("2020-11-01"); const slugPlanQuery = wixPricingPlansBackend.queryPublicPlans() .startsWith("slug", "silver") .or( wixPricingPlansBackend.queryPublicPlans() .startsWith("slug", "gold") ); const datePlanQuery = wixPricingPlansBackend.queryPublicPlans() .between("_createdDate", date, now); const typeAndDateQuery = slugPlanQuery.and(datePlanQuery); return wixPricingPlansBackend.queryPublicPlans() .ne("primary", true).and(typeAndDateQuery) .find() .then((publicPlans) => { if(publicPlans.items.length > 0) { const items = publicPlans.items; const firstItem = items[0]; const totalCount = publicPlans.totalCount; const pageSize = publicPlans.pageSize; const currentPage = publicPlans.currentPage; const totalPages = publicPlans.totalPages; const hasNext = publicPlans.hasNext(); const hasPrev = publicPlans.hasPrev(); const length = publicPlans.length; const query = publicPlans.query; } else { // handle case where no matching public plans found } } ) .catch((error) => { const queryError = error; } ); /* * The results contain public * plans with slugs that start with * "gold" or "silver": * * gold-vip * silver * silver-vip * * But not the primary public plan (slug = gold) * * And no public plans created earlier than * November 11, 2020 */ ``` ---