EcoShop is an ecommerce app made with react native using serverless function and realm database.
- Authentication.
- Add items to your whishlist
- Search Products
- Infinite list (Pagination)
- Sort with category
You can download the latest APK here.
Please clone the repo 🙃🙃🙃
# Dependencies
yarn install
or
npm install
## MongoDB Realm
Setup Realm Account
Import the ecoshop.csv file in mongo db atlas
Setup Schema and Permissions
Write the serverless functions and fetch the products
# Run IOS
yarn ios
# Run ANDROID
yarn android
exports = function (id, val, isFav) {
var collection = context.services
.get('mongodb-atlas')
.db('EcoShop')
.collection('UserDB');
if (isFav)
return collection.updateOne(
{_id: BSON.ObjectId(id)},
{$pull: {favourite: val}},
);
else
return collection.updateOne(
{_id: BSON.ObjectId(id)},
{$push: {favourite: val}},
);
};
exports = function (arg = 1) {
var collection = context.services
.get('mongodb-atlas')
.db('EcoShop')
.collection('Flipkart');
const data = collection
.find({})
.skip(arg * 20)
.limit(20)
.toArray();
return {data: data, pgNo: arg + 1};
};
exports = function (arg) {
var collection = context.services
.get('mongodb-atlas')
.db('EcoShop')
.collection('Flipkart');
return collection.distinct('product_category_tree');
};
exports = function (arg) {
var collection = context.services
.get('mongodb-atlas')
.db('EcoShop')
.collection('Flipkart');
return collection.findOne({_id: BSON.ObjectId(arg)});
};
exports = function (arg, pgNo) {
var collection = context.services
.get('mongodb-atlas')
.db('EcoShop')
.collection('Flipkart');
const data = collection
.find({product_category_tree: {$regex: arg, $options: 'i'}})
.skip(pgNo * 20)
.limit(20)
.toArray();
return {data: data, pgNo: pgNo + 1};
};
exports = function (arg, pgNo) {
var collection = context.services
.get('mongodb-atlas')
.db('EcoShop')
.collection('Flipkart');
const data = collection
.find({product_name: {$regex: arg, $options: 'i'}})
.skip(pgNo * 20)
.limit(20)
.toArray();
return {data: data, pgNo: pgNo + 1};
};
exports = function (arg1, arg2) {
const collection = context.services
.get('mongodb-atlas')
.db('EcoShop')
.collection('UserDB');
const data = collection.findOne({email: arg1, password: arg2});
return data;
};
exports = async function (item) {
const collection = context.services
.get('mongodb-atlas')
.db('EcoShop')
.collection('UserDB');
return collection
.find({$or: [{username: item.username}, {email: item.email}]})
.toArray()
.then(result => {
if (result.length == 0)
return collection.insertOne({
username: item.username,
password: item.password,
email: item.email,
favourite: [],
});
else return null;
});
};