Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const pokecrewData = new Parse.Promise();
request({
url: 'https://api.pokecrew.com/api/v1/seens',
qs: Object.assign({}, defaultArgs, args),
json: true,
}, (error, response, body) => {
if (!error && response.statusCode === 200) {
console.log('resolving with', body.seens);
pokecrewData.resolve(body.seens);
} else {
pokecrewData.reject(error);
}
});
const sightingQuery = new Parse.Query(Sighting);
sightingQuery.lessThanOrEqualTo('latitude', args.northeast_latitude);
sightingQuery.greaterThan('latitude', args.southwest_latitude);
sightingQuery.lessThanOrEqualTo('longitude', args.northeast_longitude);
sightingQuery.greaterThan('longitude', args.southwest_longitude);
return Parse.Promise.when(pokecrewData, sightingQuery.find()).then((pcData, internalData) =>
[...pcData, ...internalData.map(d => Object.assign({}, d.toJSON(), { id: d.id }))]
);
},
};
it('matches an $or query', function() {
const player = {
id: new Id('Player', 'P1'),
name: 'Player 1',
score: 12,
};
const q = new Parse.Query('Player');
q.equalTo('name', 'Player 1');
const q2 = new Parse.Query('Player');
q2.equalTo('name', 'Player 2');
const orQuery = Parse.Query.or(q, q2);
expect(matchesQuery(player, q)).toBe(true);
expect(matchesQuery(player, q2)).toBe(false);
expect(matchesQuery(player, orQuery)).toBe(true);
});
Parse.Object.saveAll([obj0, obj1, obj2]).then(() => {
spyOn(databaseAdapter.database.serverConfig, 'cursor').and.callThrough();
Parse.Cloud.beforeFind('MyObject2', req => {
req.readPreference = 'SECONDARY';
});
const query0 = new Parse.Query('MyObject0');
query0.equalTo('boolKey', false);
const query1 = new Parse.Query('MyObject1');
query1.matchesQuery('myObject0', query0);
const query2 = new Parse.Query('MyObject2');
query2.matchesQuery('myObject1', query1);
query2
.find()
.then(results => {
expect(results.length).toBe(1);
expect(results[0].get('boolKey')).toBe(false);
let myObjectReadPreference0 = null;
let myObjectReadPreference1 = null;
const network = {
orderer: {
url: `grpcs://${ordererConfig.get('url')}`,
'server-hostname': ordererConfig.get('serverHostName'),
tls_cacerts: '/var/www/app/lib/fabric/fixtures/channel/v1.0/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt',
},
};
for (const index in orgConfigs) {
const orgConfig = orgConfigs[index];
const caConfigQuery = new Parse.Query('CaConfig');
caConfigQuery.equalTo('networkConfig', networkConfig);
caConfigQuery.equalTo('sequence', orgConfig.get('sequence'));
const caConfig = await caConfigQuery.first();
const peerConfigQuery = new Parse.Query('PeerConfig');
peerConfigQuery.equalTo('networkConfig', networkConfig);
peerConfigQuery.equalTo('orgConfig', orgConfig);
peerConfigQuery.ascending('sequence');
const peerConfigs = await peerConfigQuery.find();
const peers = {};
for (const peerIndex in peerConfigs) {
const peerConfig = peerConfigs[peerIndex];
peers[`peer${peerConfig.get('sequence') + 1}`] = {
requests: `grpcs://${peerConfig.get('grpc')}`,
events: `grpcs://${peerConfig.get('event')}`,
'server-hostname': `peer${peerConfig.get('sequence')}.org${orgConfig.get('sequence')}.example.com`,
tls_cacerts: `/var/www/app/lib/fabric/fixtures/channel/v1.0/crypto-config/peerOrganizations/org${orgConfig.get('sequence')}.example.com/peers/peer${peerConfig.get('sequence')}.org${orgConfig.get('sequence')}.example.com/tls/ca.crt`,
};
}
network[`org${orgConfig.get('sequence')}`] = {
name: orgConfig.get('name'),
Promise.all(saves).then(function() {
const query = new Parse.Query("TestObject");
query.ascending("x");
return query.first();
}).then(function(obj) {
equal(obj.get("x"), 1);
tlsCACerts: {
path: '/var/www/app/lib/fabric/fixtures/channel/v1.2/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt',
},
url: `grpcs://${ordererConfig.get('url')}`,
};
const channelsPeers = {};
let network = {};
for (let index = 0; index < orgConfigCount; index++) {
const orgConfig = orgConfigs[index];
const caConfigQuery = new Parse.Query('CaConfig');
caConfigQuery.equalTo('networkConfig', networkConfig);
caConfigQuery.equalTo('sequence', orgConfig.get('sequence'));
const caConfig = await caConfigQuery.first();
const peerConfigQuery = new Parse.Query('PeerConfig');
peerConfigQuery.equalTo('networkConfig', networkConfig);
peerConfigQuery.equalTo('orgConfig', orgConfig);
peerConfigQuery.ascending('sequence');
const peerConfigs = await peerConfigQuery.find();
const peerConfigCount = await peerConfigQuery.count();
const peerNames = [];
for (let peerIndex = 0; peerIndex < peerConfigCount; peerIndex++) {
peerNames.push(`peer${peerIndex}.org${index + 1}.example.com`);
peers[`peer${peerIndex}.org${index + 1}.example.com`] = {
eventUrl: `grpcs://${peerConfigs[peerIndex].get('event')}`,
grpcOptions: {
'ssl-target-name-override': `peer${peerIndex}.org${index + 1}.example.com`,
},
tlsCACerts: {
path: `/var/www/app/lib/fabric/fixtures/channel/v1.2/crypto-config/peerOrganizations/org${index + 1}.example.com/peers/peer${peerIndex}.org${index + 1}.example.com/tls/ca.crt`,
}).then(() => {
const inQuery = new Parse.Query('ContainedObject');
inQuery.greaterThanOrEqualTo('index', 1);
const query = new Parse.Query('Container');
query.matchesQuery('objects', inQuery);
return query.find();
}).then((results) => {
if (results) {
obj.save().then(function() {
const query = new Parse.Query(TestObject);
query.find().then(function(results) {
equal(results.length, 1);
equal(results[0].get("length"), 5);
done();
}, function(error) {
ok(false, error.message);
done();
});
}, function(error) {
ok(false, error.message);
q.equalTo('name', 'bill');
expect(matchesQuery(obj, q)).toBe(false);
let img = {
id: new Id('Image', 'I1'),
tags: ['nofilter', 'latergram', 'tbt'],
};
q = new Parse.Query('Image');
q.equalTo('tags', 'selfie');
expect(matchesQuery(img, q)).toBe(false);
q.equalTo('tags', 'tbt');
expect(matchesQuery(img, q)).toBe(true);
const q2 = new Parse.Query('Image');
q2.containsAll('tags', ['latergram', 'nofilter']);
expect(matchesQuery(img, q2)).toBe(true);
q2.containsAll('tags', ['latergram', 'selfie']);
expect(matchesQuery(img, q2)).toBe(false);
const u = new Parse.User();
u.id = 'U2';
q = new Parse.Query('Image');
q.equalTo('owner', u);
img = {
className: 'Image',
objectId: 'I1',
owner: {
className: '_User',
objectId: 'U2',
q = new Parse.Query('Person');
q.greaterThan('score', 15);
expect(matchesQuery(player, q)).toBe(false);
q.greaterThan('score', 10);
expect(matchesQuery(player, q)).toBe(true);
q = new Parse.Query('Person');
q.greaterThanOrEqualTo('score', 15);
expect(matchesQuery(player, q)).toBe(false);
q.greaterThanOrEqualTo('score', 12);
expect(matchesQuery(player, q)).toBe(true);
q.greaterThanOrEqualTo('score', 10);
expect(matchesQuery(player, q)).toBe(true);
q = new Parse.Query('Person');
q.notEqualTo('score', 12);
expect(matchesQuery(player, q)).toBe(false);
q.notEqualTo('score', 40);
expect(matchesQuery(player, q)).toBe(true);
});