Definición
cursor.maxAwaitTimeMS(<time limit>)Importante
Método mongosh
This page documents a
mongoshmethod. This is not the documentation for a language-specific driver, such as Node.js.Para los drivers de API de MongoDB, consulte la documentación del driver de MongoDB específica del lenguaje.
Especifica el tiempo máximo que el servidor debe esperar nuevos documentos que coincidan con una query de cursor con seguimiento en una colección con tamaño fijo. Para obtener más información sobre cómo iterar un cursor devuelto por una query, consulta: Itera un cursor en
mongosh.The
maxAwaitTimeMS()method has the following prototype form:db.collection.find( { <query> }, { <projection> } ).tailable( { awaitData: true } ).maxAwaitTimeMS( <milliseconds> ) The
maxAwaitTimeMS()method has the following parameter:ParameterTipoDescripciónmillisecondsentero
Especifica un tiempo máximo de espera para los nuevos documentos.
Importante
This method, maxAwaitTimeMS(), sets a limit on how long a tailable cursor waits for the next response. maxTimeMS() sets a limit on total processing time.
Compatibilidad
Este método está disponible en implementaciones alojadas en los siguientes entornos:
- MongoDB Atlas: El servicio totalmente gestionado para implementaciones de MongoDB en la nube
Nota
This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see Unsupported Commands.
MongoDB Enterprise: La versión basada en suscripción y autogestionada de MongoDB
MongoDB Community: La versión de MongoDB con código fuente disponible, de uso gratuito y autogestionada.
Ejemplo
Query la limitada sales colección para encontrar los totales semanales de ventas del agente Mary Kay:
db.sales.find( { agent: "Mary Kay" }, { _id: 0, agent: 1, weeklyTotal: 1 } ).tailable( { awaitData: true } ).maxAwaitTimeMS( 1000 )
The highlighted line creates a tailable cursor on the sales collection. The maxAwaitTimeMS() sets a one second maximum wait time for the next cursor update.