|
1358 | 1358 | }, |
1359 | 1359 | of: function(model) { |
1360 | 1360 | var tableName; |
| 1361 | + |
1361 | 1362 | if (Utils.isString(model)) { |
1362 | | - if (model.toLowerCase() === 'users') { |
1363 | | - throw new Error("Table 'Users' is not accessible through this signature. Use Backendless.Data.of( BackendlessUser.class ) instead"); |
1364 | | - } |
1365 | 1363 | tableName = model; |
1366 | 1364 | } else { |
1367 | 1365 | tableName = getClassName.call(model); |
1368 | 1366 | } |
| 1367 | + |
1369 | 1368 | var store = dataStoreCache[tableName]; |
| 1369 | + |
1370 | 1370 | if (!store) { |
1371 | 1371 | store = new DataStore(model); |
1372 | 1372 | dataStoreCache[tableName] = store; |
|
1484 | 1484 | } |
1485 | 1485 | }; |
1486 | 1486 |
|
1487 | | - function User() { |
| 1487 | + function User(user) { |
| 1488 | + user = user || {}; |
| 1489 | + |
| 1490 | + for (var prop in user) { |
| 1491 | + this[prop] = user[prop] |
| 1492 | + } |
1488 | 1493 | } |
1489 | 1494 |
|
1490 | 1495 | User.prototype.___class = "Users"; |
|
1585 | 1590 | return this.roleHelper(identity, rolename, async, 'unassignRole'); |
1586 | 1591 | }, |
1587 | 1592 |
|
1588 | | - login: function(username, password, stayLoggedIn, async) { |
1589 | | - if (!username) { |
1590 | | - throw new Error('Username can not be empty'); |
| 1593 | + login: function(login, password, stayLoggedIn, async) { |
| 1594 | + if (!login) { |
| 1595 | + throw new Error('Login can not be empty'); |
1591 | 1596 | } |
1592 | 1597 |
|
1593 | 1598 | if (!password) { |
|
1608 | 1613 | } |
1609 | 1614 |
|
1610 | 1615 | var data = { |
1611 | | - login : username, |
| 1616 | + login : login, |
1612 | 1617 | password: password |
1613 | 1618 | }; |
1614 | 1619 |
|
|
1631 | 1636 | _getUserFromResponse: function(user) { |
1632 | 1637 | Backendless.LocalCache.set("current-user-id", user.objectId); |
1633 | 1638 |
|
1634 | | - var newUser = new Backendless.User(); |
| 1639 | + var userToken = user['user-token'] |
1635 | 1640 |
|
1636 | | - for (var i in user) { |
1637 | | - if (user.hasOwnProperty(i)) { |
1638 | | - if (i == 'user-token') { |
1639 | | - if (Backendless.LocalCache.get("stayLoggedIn")) { |
1640 | | - Backendless.LocalCache.set("user-token", user[i]); |
1641 | | - } |
1642 | | - continue; |
1643 | | - } |
1644 | | - newUser[i] = user[i]; |
1645 | | - } |
| 1641 | + if (userToken && Backendless.LocalCache.get('stayLoggedIn')) { |
| 1642 | + Backendless.LocalCache.set('user-token', userToken) |
1646 | 1643 | } |
1647 | 1644 |
|
1648 | | - return newUser; |
| 1645 | + return new Backendless.User(user); |
1649 | 1646 | }, |
1650 | 1647 |
|
1651 | 1648 | loggedInUser: function() { |
|
4498 | 4495 | currentUser = null; |
4499 | 4496 | }; |
4500 | 4497 |
|
4501 | | - var DataQuery = function () { |
4502 | | - this.properties = []; |
4503 | | - this.condition = null; |
4504 | | - this.options = null; |
4505 | | - this.url = null; |
| 4498 | + var DataQuery = function (args) { |
| 4499 | + args = args || {}; |
| 4500 | + |
| 4501 | + this.properties = args.properties || []; |
| 4502 | + this.condition = args.condition || null; |
| 4503 | + this.options = args.options || null; |
| 4504 | + this.url = args.url || null; |
4506 | 4505 | }; |
4507 | 4506 |
|
4508 | 4507 | DataQuery.prototype = { |
|
4512 | 4511 | } |
4513 | 4512 | }; |
4514 | 4513 |
|
4515 | | - var GeoQuery = function() { |
4516 | | - this.searchRectangle = undefined; |
4517 | | - this.categories = []; |
4518 | | - this.includeMetadata = true; |
4519 | | - this.metadata = undefined; |
4520 | | - this.condition = undefined; |
4521 | | - this.relativeFindMetadata = undefined; |
4522 | | - this.relativeFindPercentThreshold = undefined; |
4523 | | - this.pageSize = undefined; |
4524 | | - this.latitude = undefined; |
4525 | | - this.longitude = undefined; |
4526 | | - this.radius = undefined; |
4527 | | - this.units = undefined; |
4528 | | - this.degreePerPixel = undefined; |
4529 | | - this.clusterGridSize = undefined; |
| 4514 | + var GeoQuery = function(args) { |
| 4515 | + args = args || {}; |
| 4516 | + |
| 4517 | + this.searchRectangle = args.searchRectangle || undefined; |
| 4518 | + this.categories = args.categories || []; |
| 4519 | + this.includeMetadata = args.includeMetadata || true; |
| 4520 | + this.metadata = args.metadata || undefined; |
| 4521 | + this.condition = args.condition || undefined; |
| 4522 | + this.relativeFindMetadata = args.relativeFindMetadata || undefined; |
| 4523 | + this.relativeFindPercentThreshold = args.relativeFindPercentThreshold || undefined; |
| 4524 | + this.pageSize = args.pageSize || undefined; |
| 4525 | + this.latitude = args.latitude || undefined; |
| 4526 | + this.longitude = args.longitude || undefined; |
| 4527 | + this.radius = args.radius || undefined; |
| 4528 | + this.units = args.units || undefined; |
| 4529 | + this.degreePerPixel = args.degreePerPixel || undefined; |
| 4530 | + this.clusterGridSize = args.clusterGridSize || undefined; |
4530 | 4531 | }; |
4531 | 4532 |
|
4532 | 4533 | GeoQuery.prototype = { |
|
0 commit comments