Skip to content

Commit 7a8c275

Browse files
authored
Merge branch 'alpha' into event-emitter
2 parents 2202981 + c7b391d commit 7a8c275

File tree

9 files changed

+82
-9
lines changed

9 files changed

+82
-9
lines changed

changelogs/CHANGELOG_alpha.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# [4.2.0-alpha.6](https://github.com/parse-community/Parse-SDK-JS/compare/4.2.0-alpha.5...4.2.0-alpha.6) (2023-08-27)
2+
3+
4+
### Features
5+
6+
* Add Bytes type to `Parse.Schema` ([#2001](https://github.com/parse-community/Parse-SDK-JS/issues/2001)) ([343d0d7](https://github.com/parse-community/Parse-SDK-JS/commit/343d0d729a57acdd3c9ba5c1dbe5738b3916ea04))
7+
8+
# [4.2.0-alpha.5](https://github.com/parse-community/Parse-SDK-JS/compare/4.2.0-alpha.4...4.2.0-alpha.5) (2023-08-27)
9+
10+
11+
### Features
12+
13+
* Add support for excluding keys in `ParseQuery.findAll` ([#2000](https://github.com/parse-community/Parse-SDK-JS/issues/2000)) ([012ba4c](https://github.com/parse-community/Parse-SDK-JS/commit/012ba4cdab1e3f853625f507c713cef2264a40dd))
14+
115
# [4.2.0-alpha.4](https://github.com/parse-community/Parse-SDK-JS/compare/4.2.0-alpha.3...4.2.0-alpha.4) (2023-07-23)
216

317

integration/test/ParseQueryTest.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,6 +1621,23 @@ describe('Parse Query', () => {
16211621
assert.equal(result.get('slice'), 'pizza');
16221622
});
16231623

1624+
it('can exclude keys in findAll', async () => {
1625+
const object = new TestObject({
1626+
hello: 'world',
1627+
foo: 'bar',
1628+
slice: 'pizza',
1629+
});
1630+
await object.save();
1631+
1632+
const query = new Parse.Query(TestObject);
1633+
query.exclude('foo');
1634+
query.equalTo('objectId', object.id);
1635+
const [result] = await query.findAll();
1636+
assert.equal(result.get('foo'), undefined);
1637+
assert.equal(result.get('hello'), 'world');
1638+
assert.equal(result.get('slice'), 'pizza');
1639+
});
1640+
16241641
it('uses subclasses when creating objects', done => {
16251642
const ParentObject = Parse.Object.extend({ className: 'ParentObject' });
16261643
let ChildObject = Parse.Object.extend('ChildObject', {

integration/test/ParseSchemaTest.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ describe('Schema', () => {
7272
.addString('stringField')
7373
.addNumber('numberField')
7474
.addBoolean('booleanField')
75+
.addBytes('bytesField')
7576
.addDate('dateField')
7677
.addFile('fileField')
7778
.addGeoPoint('geoPointField')
@@ -91,6 +92,7 @@ describe('Schema', () => {
9192
assert.equal(result.fields.stringField.type, 'String');
9293
assert.equal(result.fields.numberField.type, 'Number');
9394
assert.equal(result.fields.booleanField.type, 'Boolean');
95+
assert.equal(result.fields.bytesField.type, 'Bytes');
9496
assert.equal(result.fields.dateField.type, 'Date');
9597
assert.equal(result.fields.fileField.type, 'File');
9698
assert.equal(result.fields.geoPointField.type, 'GeoPoint');
@@ -182,6 +184,7 @@ describe('Schema', () => {
182184
required: true,
183185
defaultValue: '2000-01-01T00:00:00.000Z',
184186
})
187+
.addBytes('bytesField', { required: true, defaultValue: 'ParseA==' })
185188
.addFile('fileField', { required: true, defaultValue: file })
186189
.addGeoPoint('geoPointField', { required: true, defaultValue: point })
187190
.addPolygon('polygonField', { required: true, defaultValue: polygon })
@@ -204,6 +207,11 @@ describe('Schema', () => {
204207
stringField: { type: 'String', required: true, defaultValue: 'world' },
205208
numberField: { type: 'Number', required: true, defaultValue: 10 },
206209
booleanField: { type: 'Boolean', required: true, defaultValue: false },
210+
bytesField: {
211+
type: 'Bytes',
212+
required: true,
213+
defaultValue: { __type: 'Bytes', base64: 'ParseA==' },
214+
},
207215
dateField: {
208216
type: 'Date',
209217
required: true,
@@ -245,6 +253,7 @@ describe('Schema', () => {
245253
stringField: 'world',
246254
numberField: 10,
247255
booleanField: false,
256+
bytesField: { __type: 'Bytes', base64: 'ParseA==' },
248257
dateField: { __type: 'Date', iso: '2000-01-01T00:00:00.000Z' },
249258
dateStringField: { __type: 'Date', iso: '2000-01-01T00:00:00.000Z' },
250259
fileField: file.toJSON(),

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "parse",
3-
"version": "4.2.0-alpha.4",
3+
"version": "4.2.0-alpha.6",
44
"description": "Parse JavaScript SDK",
55
"homepage": "https://parseplatform.org",
66
"keywords": [

src/ParseQuery.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -948,13 +948,10 @@ class ParseQuery {
948948

949949
const query = new ParseQuery(this.className);
950950
query._limit = options.batchSize || 100;
951-
query._include = this._include.map(i => {
952-
return i;
953-
});
951+
query._include = [...this._include];
952+
query._exclude = [...this._exclude];
954953
if (this._select) {
955-
query._select = this._select.map(s => {
956-
return s;
957-
});
954+
query._select = [...this._select];
958955
}
959956
query._hint = this._hint;
960957
query._where = {};

src/ParseSchema.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const FIELD_TYPES = [
1212
'String',
1313
'Number',
1414
'Boolean',
15+
'Bytes',
1516
'Date',
1617
'File',
1718
'GeoPoint',
@@ -242,6 +243,14 @@ class ParseSchema {
242243
};
243244
}
244245
}
246+
if (type === 'Bytes') {
247+
if (options && options.defaultValue) {
248+
fieldOptions.defaultValue = {
249+
__type: 'Bytes',
250+
base64: options.defaultValue,
251+
};
252+
}
253+
}
245254
this._fields[name] = fieldOptions;
246255
return this;
247256
}
@@ -303,6 +312,17 @@ class ParseSchema {
303312
return this.addField(name, 'Boolean', options);
304313
}
305314

315+
/**
316+
* Adding Bytes Field
317+
*
318+
* @param {string} name Name of the field that will be created on Parse
319+
* @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
320+
* @returns {Parse.Schema} Returns the schema, so you can chain this call.
321+
*/
322+
addBytes(name: string, options: FieldOptions) {
323+
return this.addField(name, 'Bytes', options);
324+
}
325+
306326
/**
307327
* Adding Date Field
308328
*

src/__tests__/ParseQuery-test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,6 +1817,7 @@ describe('ParseQuery', () => {
18171817
q.select('size', 'name');
18181818
q.includeAll();
18191819
q.hint('_id_');
1820+
q.exclude('foo')
18201821

18211822
await q.findAll();
18221823
expect(findMock).toHaveBeenCalledTimes(1);
@@ -1827,6 +1828,7 @@ describe('ParseQuery', () => {
18271828
order: 'objectId',
18281829
keys: 'size,name',
18291830
include: '*',
1831+
excludeKeys: 'foo',
18301832
hint: '_id_',
18311833
where: {
18321834
size: {

src/__tests__/ParseSchema-test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ describe('ParseSchema', () => {
5757
.addString('stringField')
5858
.addNumber('numberField')
5959
.addBoolean('booleanField')
60+
.addBytes('bytesField')
6061
.addDate('dateField')
6162
.addFile('fileField')
6263
.addGeoPoint('geoPointField')
@@ -70,6 +71,7 @@ describe('ParseSchema', () => {
7071
expect(schema._fields.stringField.type).toEqual('String');
7172
expect(schema._fields.numberField.type).toEqual('Number');
7273
expect(schema._fields.booleanField.type).toEqual('Boolean');
74+
expect(schema._fields.bytesField.type).toEqual('Bytes');
7375
expect(schema._fields.dateField.type).toEqual('Date');
7476
expect(schema._fields.fileField.type).toEqual('File');
7577
expect(schema._fields.geoPointField.type).toEqual('GeoPoint');
@@ -103,6 +105,10 @@ describe('ParseSchema', () => {
103105
required: true,
104106
defaultValue: 'hello',
105107
})
108+
.addBytes('bytesField', {
109+
required: true,
110+
defaultValue: 'ParseA==',
111+
})
106112
.addDate('dateField', {
107113
required: true,
108114
defaultValue: '2000-01-01T00:00:00.000Z',
@@ -131,6 +137,14 @@ describe('ParseSchema', () => {
131137
iso: new Date('2000-01-01T00:00:00.000Z'),
132138
},
133139
});
140+
expect(schema._fields.bytesField).toEqual({
141+
type: 'Bytes',
142+
required: true,
143+
defaultValue: {
144+
__type: 'Bytes',
145+
base64: 'ParseA==',
146+
},
147+
});
134148
});
135149

136150
it('can create schema indexes', done => {

0 commit comments

Comments
 (0)