Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function deleteTableEntities (tables) {
const deletions = []
for (let index = 0; index < tables.length; index++) {
const table = tables[index]
const query = new azure.TableQuery() // Azure Table Storage has a max of 1000 records returned
let done = false
let batch = 1
while (!done) {
const data = await tableService.queryEntitiesAsync(table, query, null)
const entities = data.result.entries
if (entities.length === 0) {
done = true
}
console.log(`Found ${entities.length} entities to delete in batch ${batch++} from ${table}`)
entities.forEach(entity => {
deletions.push(tableService.deleteEntityAsync(table, entity))
})
await Promise.all(deletions)
}
}
}
} else if (typeof teamsIn === 'function') {
callback = teamsIn;
teams = []; // Special case: empty list means all pending approvals
} else {
if (!(teamsIn && teamsIn.length)) {
throw new Error('Unknown "teams" type for getPendingApprovals. Please file a bug.');
}
// New permissions system refactoring...
if (teamsIn.length > 0 && teamsIn[0] && teamsIn[0].id) {
teams = [];
for (i = 0; i < teamsIn.length; i++) {
teams.push(teamsIn[i].id);
}
}
}
var query = new azure.TableQuery()
.where('PartitionKey eq ?', this.options.partitionKey)
.and('active eq ?', true);
if (teams.length > 0) {
var clauses = [];
for (i = 0; i < teams.length; i++) {
clauses.push('teamid eq ?string?');
}
var args = [clauses.join(' or ')].concat(teams);
query.and.apply(query, args);
}
dc.table.queryEntities(dc.options.pendingApprovalsTableName,
query,
null,
function (error, results) {
if (error) return callback(error);
var entries = [];
DataClient.prototype.getUserLinks = function gul(users, callback) {
var dc = this;
var query = new azure.TableQuery()
.where('PartitionKey eq ?', this.options.partitionKey);
if (!(users && users.length && users.length > 0)) {
return callback(new Error('Must include an array of GitHub user IDs, and at least one in that array.'));
}
var clauses = [];
if (users.length > 250) {
// TODO: Write better code here to use continuation tokens and utilities to resolve any number from storage.
return callback(new Error(`The application has queried for ${users.length} entities, which is too many for the current design.`));
}
for (var i = 0; i < users.length; i++) {
clauses.push('ghid eq ?string?');
}
var args = [clauses.join(' or ')].concat(users);
query.and.apply(query, args);
dc.table.queryEntities(dc.options.linksTableName,
query,
function FetchSiteDefinitions(siteId, tableService, callback){
const queryString = `PartitionKey eq ?${siteId ? ' and RowKey eq ?' : ''}`;
const query = new azureStorage.TableQuery().where(queryString, AZURE_TBL_SITES_PARTITION_KEY, siteId);
tableService.createTableIfNotExists(AZURE_TBL_SITES, (error, result, response) => { // eslint-disable-line no-unused-vars
if(!error){
tableService.queryEntities(AZURE_TBL_SITES, query, null, (error, result, response) => { // eslint-disable-line no-unused-vars
if(!error){
const siteEntities = result.entries.map(site => {
return {
'name': site.RowKey._,
'properties': {
'logo': site.logo ? site.logo._ : '',
'title': site.title ? site.title._ : '',
'supportedLanguages': site.supportedLanguages ? JSON.parse(site.supportedLanguages._) : [],
'defaultZoomLevel': site.defaultZoomLevel._,
'fbToken': site.fbToken ? site.fbToken._ : '',
'mapzenApiKey': site.mapzenApiKey ? site.mapzenApiKey._ : '',
'targetBbox': site.targetBbox ? JSON.parse(site.targetBbox._) : [],
function missingEntityFindTest(cb) {
const query = new azureStorage.TableQuery()
.top(5)
.where("RowKey eq ?", "unknownRowKeyForFindError");
const faillingFindTableService = azureStorage.createTableService(
"UseDevelopmentStorage=true"
);
faillingFindTableService.queryEntities(tableName, query, null, function(
error,
result,
response
) {
expect(error.message).to.equal(EntityNotFoundErrorMessage);
expect(response.statusCode).to.equal(404);
cb();
});
}
});
return new Promise((resolve, reject) => {
var query = new azure.TableQuery()
.where('PartitionKey eq ?', userId.toString())
tableService.queryEntities('userRepositories', query, null, function(error, result) {
if (error) {
console.log(error)
reject(error)
return
}
console.log(`Got ${result.entries.length} repositories`)
resolve(_.sortBy(result.entries.map(repo => ({
userId: repo.PartitionKey._,
repoId: repo.RowKey._,
repoName: repo.RepoName._,
selected: repo.Selected._
})), 'repoName'))
})
})
getFromPreparedCheckTableStorage: async function getFromPreparedCheckTableStorage (azureTableService, checkCode, logger) {
const query = new azureStorage.TableQuery()
.top(1)
.where(TableQuery.guidFilter('checkCode', QueryComparisons.EQUAL, checkCode))
let check
try {
const data = await azureTableService.queryEntitiesAsync(preparedCheckTable, query, null)
check = data.response.body.value[0]
} catch (error) {
const msg = `getFromPreparedCheckTableStorage(): error during retrieve for table storage check for checkCode [${checkCode}]`
logger.error(msg)
logger.error(error.message)
throw new Error(msg)
}
if (!check) {
const msg = `getFromPreparedCheckTableStorage(): check does not exist: [${checkCode}]`
var queryEntity = function (table, fromcolumn, where, selectdata) {
node.log('query entity');
var query = new Client.TableQuery()
.top(1)
.where(entityClass.fromcolumn + ' eq ?', entityClass.where);
clientTableService.queryEntities(entityClass.tableName, query, null, function(err, result, response){
if (err) {
node.error('Error while trying to query entity:' + err.toString());
setStatus(statusEnum.error);
} else {
//node.log(JSON.stringify(result.entries.data));
//setStatus(statusEnum.sent);
//node.send(result.entries.data._);
}
});
}
TrainingImageService.prototype.list = function (projectId, currentToken, requestedLimit) {
const limit = requestedLimit ? parseInt(requestedLimit) : 128;
const tableQuery = new azureStorage.TableQuery().top(limit).where('PartitionKey == ?', projectId);
return storageFoundation.queryEntities(this.tableService, this.trainingImagesTableName, tableQuery, currentToken).then(result => {
const records = result.entries.map(entity => {
return this.mapEntityToImage(entity);
});
return {
currentToken: result.continuationToken,
limit: limit,
entries: records
};
});
}
app.get('/api/temperatures', function(req, res) {
var query = new azure.TableQuery()
.select(['eventtime', 'temperaturereading', 'deviceid'])
.where('PartitionKey eq ?', deviceId);
var nextContinuationToken = null;
var fullresult = { entries: [] };
queryTable(storageTable, query, nextContinuationToken, fullresult, function (err, result, response) {
res.json(result.entries.slice(-10));
})
})