Skip to content

Commit

Permalink
api fulltext search
Browse files Browse the repository at this point in the history
  • Loading branch information
saigonbitmaster committed Feb 13, 2023
1 parent 4ccd0f6 commit f8c2dcc
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 7 deletions.
5 changes: 5 additions & 0 deletions api/src/flatworks/utils/getlist.ts
Expand Up @@ -14,6 +14,9 @@ to: {
{ 'Content-Range': result.count,
'Access-Control-Expose-Headers': 'Content-Range'};
data: [{_id: '', field: ''}]
fullText search: filter: { textSearch: 'text' } -> filter: $text: { $search: 'text' }
*/

const queryTransform = (query): MongooseQuery => {
Expand All @@ -27,6 +30,8 @@ const queryTransform = (query): MongooseQuery => {
const limit = rangeEnd - rangeStart + 1;
const skip = rangeStart;
const filter = query.filter ? JSON.parse(query.filter) : {};
//need to add text search for reference collections
filter.textSearch ? (filter.$text = { $search: filter.textSearch }) : null;
return { filter, sort, skip, limit };
};

Expand Down
1 change: 1 addition & 0 deletions api/src/jobbid/schemas/schema.ts
Expand Up @@ -42,5 +42,6 @@ export class JobBid {

const JobBidSchema = SchemaFactory.createForClass(JobBid);
JobBidSchema.plugin(uniqueValidator);
JobBidSchema.index({ name: 'text' });

export { JobBidSchema };
1 change: 1 addition & 0 deletions api/src/jobtask/schemas/schema.ts
Expand Up @@ -48,5 +48,6 @@ export class JobTask {

const JobTaskSchema = SchemaFactory.createForClass(JobTask);
JobTaskSchema.plugin(uniqueValidator);
JobTaskSchema.index({ name: 'text' });

export { JobTaskSchema };
1 change: 1 addition & 0 deletions api/src/postjob/schemas/schema.ts
Expand Up @@ -54,5 +54,6 @@ export class PostJob {

const PostJobSchema = SchemaFactory.createForClass(PostJob);
PostJobSchema.plugin(uniqueValidator);
PostJobSchema.index({ name: 'text' });

export { PostJobSchema };
1 change: 1 addition & 0 deletions api/src/skill/schemas/schema.ts
Expand Up @@ -18,5 +18,6 @@ export class Skill {

const SkillSchema = SchemaFactory.createForClass(Skill);
SkillSchema.plugin(uniqueValidator);
SkillSchema.index({ name: 'text' });

export { SkillSchema };
4 changes: 3 additions & 1 deletion api/src/user/schemas/user.schema.ts
Expand Up @@ -23,5 +23,7 @@ export class User {
@Prop()
deletedAt?: Date;
}
const UserSchema = SchemaFactory.createForClass(User);
UserSchema.index({ name: 'text', fullName: 'text' });

export const UserSchema = SchemaFactory.createForClass(User);
export { UserSchema };
10 changes: 8 additions & 2 deletions emp/src/postjobs/list.tsx
Expand Up @@ -8,15 +8,21 @@ import {
SingleFieldList,
ChipField,
ReferenceArrayField,
ReferenceField
ReferenceField,
TextInput
} from "react-admin";
import CurrencyNumberField from "../components/currencyNumberField";

import LinkBidField from "../components/linkBidsField";

const filters = [
<TextInput label="Search" source="textSearch" alwaysOn />
];


const ListScreen = () => {
return (
<List perPage={25} sort={{ field: "date", order: "desc" }} hasCreate filter={{queryType: "employer"}}>
<List filters = {filters} perPage={25} sort={{ field: "date", order: "desc" }} hasCreate filter={{queryType: "employer"}}>
<Datagrid>
<TextField source="name" />
<LinkBidField />
Expand Down
14 changes: 10 additions & 4 deletions emp/src/wallet/wallet.tsx
Expand Up @@ -181,6 +181,9 @@ const Wallet = (props) => {
const [walletState, setWalletState] = React.useState({
hasWallet: false,
address: "",
pKeyHash: "",
pKeyHashBech32: ""

});

const { data, total, isLoading, error } = useGetList("wallets", {
Expand All @@ -199,6 +202,8 @@ const Wallet = (props) => {
setWalletState({
hasWallet: true,
address: wallet.address,
pKeyHash: wallet.pKeyHash,
pKeyHashBech32: wallet.pKeyHashBech32
});
}, [wallet]);

Expand All @@ -221,7 +226,7 @@ const Wallet = (props) => {
const handleClick = () => {
createWallet("wallets", { data: walletData });
};

console.log(walletState)
return (
<Box>
<Grid
Expand All @@ -233,10 +238,11 @@ const Wallet = (props) => {
{walletState.hasWallet ? (
<>
<Typography variant="body1">Your wallet</Typography>
<Typography variant="body1">{walletState.address}</Typography>
<Typography variant="body2" sx={{ color: "red" }}>
<Typography variant="body1">Address: {walletState.address}</Typography>
<Typography variant="body1">PublicKey hash Bench32: {walletState.pKeyHashBech32}</Typography>
{/* <Typography variant="body2" sx={{ color: "red" }}>
{"$ADA 10000"}
</Typography>
</Typography> */}
</>
) : !create ? (
<Typography variant="body1">No registered wallet</Typography>
Expand Down

0 comments on commit f8c2dcc

Please sign in to comment.