MCPcopy Create free account
hub / github.com/apache/cassandra-nodejs-driver / getUdt

Method getUdt

lib/metadata/schema-parser.js:209–248  ·  view source on GitHub ↗

* @param {String} keyspaceName * @param {String} name * @param {Object} cache * @returns {Promise }

(keyspaceName, name, cache)

Source from the content-addressed store, hash-verified

207 * @returns {Promise<Object|null>}
208 */
209 async getUdt(keyspaceName, name, cache) {
210 let udtInfo = cache && cache[name];
211 if (!udtInfo) {
212 udtInfo = new events.EventEmitter();
213 if (cache) {
214 cache[name] = udtInfo;
215 }
216 udtInfo.setMaxListeners(0);
217 udtInfo.loading = false;
218 udtInfo.name = name;
219 udtInfo.keyspace = keyspaceName;
220 udtInfo.fields = null;
221 }
222 if (udtInfo.fields) {
223 return udtInfo;
224 }
225 if (udtInfo.loading) {
226 return promiseUtils.fromEvent(udtInfo, 'load');
227 }
228 udtInfo.loading = true;
229 const query = format(this.selectUdt, keyspaceName, name);
230 try {
231 const row = await this._getFirstRow(query);
232 if (!row) {
233 udtInfo.loading = false;
234 udtInfo.emit('load', null, null);
235 return null;
236 }
237 await this._parseUdt(udtInfo, row);
238 udtInfo.emit('load', null, udtInfo);
239 return udtInfo;
240 }
241 catch (err) {
242 udtInfo.emit('load', err);
243 throw err;
244 }
245 finally {
246 udtInfo.loading = false;
247 }
248 }
249
250 /**
251 * Parses the udt information from the row

Callers

nothing calls this directly

Calls 2

_getFirstRowMethod · 0.95
_parseUdtMethod · 0.95

Tested by

no test coverage detected