0

I am using realtime datebase. I need to make a request to the server by key value. I can create a query if the value entered by the user matches the value of the key, for this I use equalTo().

const db = getDatabase(appFirebase)
const dbRef = ref(db, 'products')
const getData = async () => {
  const data = await get(query(dbRef, orderByChild('name'), equalTo('118370')))
  console.log(data.val())
  return data.val()
}
getData()

but how do I return an object that has a name property with a value of "45180 Bearing 118370, 142088, CA0118370, 141591, 6195530M91, 399037"?

name: '45180 Bearing 118370, 142088, CA0118370, 141591, 6195530M91, 399037'

How to check if a substring exists in a string?

Frank van Puffelen
  • 499,950
  • 69
  • 739
  • 734
  • There is no way to check whether a certain property value contains a specific substring. If your use-case requires that, consider using an add-on solution (such as Algolia, Elastic, or TypeSense), or switching to a database that supports the text search you need natively. – Frank van Puffelen Jan 22 '22 at 20:02

0 Answers0