Skip to content

Releases: alexvcasillas/graphdb

1.5.1 – RegExp matching values

28 Aug 13:41
Compare
Choose a tag to compare

Simple query with RegExp as value to match against

const queryResult = userCollection?.query({
  'name', new RegExp(/Al{1,1}/ig)
});

Complex query with RegExp as value to match against

const queryResult = userCollection?.query({
  'name', { match: new RegExp(/Al{1,1}/ig) }
});

v1.2.2

01 Mar 11:55
Compare
Choose a tag to compare

This version includes the new collection.on functionality which allows the user to be aware that changes of any of this types: create, update, remove, populate has ocurred.

This is useful in order to bind this library with other libraries that makes use of reactive data like React, so you can easily build a hook like the following:

import { useState, useEffect } from 'react';
import { userCollection } from '../my-collections/user.collection';

export function userOn(type: 'create' | 'update' | 'remove' | 'populate') {
  const [timestamp, setTimestamp] = useState<string>();
  useEffect(() => {
    const stopListener = userCollection?.on(type, () => {
      setTimestamp(new Date().toUTCString());
    });
    return () => stopListener();
  }, [setTimestamp])
}

Which will cause a re-render of the component using the hook when a new document is added to the collection, for example to updating lists in React or React Native.