Check out example codes for "mongodb custom IIdGenerator". It will help you in understanding the concepts better.

Code Example 1

public class GuidIdGenerator : IIdGenerator
{
    public object GenerateId(object container, object document)
    {
        return Guid.NewGuid().ToString();
    }

    public bool IsEmpty(object id)
    {
    	return !(id is string guid) || string.IsNullOrEmpty(guid);
	}
}

Learn ReactJs, React Native from akashmittal.com