josx / ra-data-feathers

A feathers rest client for react-admin
MIT License
157 stars 53 forks source link

Duplicated Presentation when using mongoose #25

Closed 1beb closed 7 years ago

1beb commented 7 years ago

I have a feathers service that I can test with postman, and it shows a list of 4 records all distinct. However, when I try to use it with aor-feathers-client, no matter which model I use, the records are all being presented as equal. So let's say for example, we have a model for reminders. We would expect:

Reminders List

But what is appearing is:

Reminder List

screenshot 2017-07-04 17 33 46

Where the first item is always duplicated. Also, when trying to edit, it simply passes 'undefined'. I'm not sure what I'm doing wrong here. I based it entirely off of your example:

// App.js

import React from 'react';
import { Admin, Resource, simpleRestClient } from 'admin-on-rest';
import { RemindersList} from './Reminders';
import { restClient } from 'aor-feathers-client'; // authClient for future!
import feathersClient from './feathersClient';

const App = () => (
  <Admin restClient={restClient(feathersClient)}>
    <Resource name="reminders" list={ContactList} />
  </Admin>
);

export default App;

// Contact.js

import React from 'react';
import { Filter, DisabledInput, ReferenceInput, List, Edit, Create, SimpleForm, Datagrid, TextField, SelectInput, TextInput, EditButton } from 'admin-on-rest/lib/mui';

export const RemindersList = (props) => (
    <List {...props}>
        <Datagrid>
            <TextField source="_id" />
            <TextField source="credoId" />
            <TextField source="surveyId" />
            <TextField source="frequency" />
            <TextField source="nextReminder" />
            <EditButton />

        </Datagrid>
    </List>
);

// feathersClient.js

import feathers from 'feathers-client';
import hooks from 'feathers-hooks';
import rest from 'feathers-rest/client';

const host = 'http://localhost:3030';

export default feathers()
  .configure(hooks())
  .configure(rest(host).fetch(window.fetch.bind(window)));
1beb commented 7 years ago

This problem appears to be related to the ids, or more specifically the field name of the id (in this case _id). In general, it seems to work if we do not use a mongoose.

josx commented 7 years ago

is there any errors on browser console or on feathers debug?

josx commented 7 years ago

check here:

https://github.com/feathersjs/feathers-mongoose/issues/81 https://github.com/feathersjs/feathers-mongoose/issues/156

@fonzarely Is working to support custom id (maybe you want to help) https://github.com/josx/aor-feathers-client/pull/21

thngdude commented 7 years ago

I am experiencing this issue as well. Any workarounds?

josx commented 7 years ago

It seems to be that you are using mongo or somehting with custom id field name. We are working to support that! @thngdude if you can please help us! here WIP https://github.com/josx/aor-feathers-client/pull/21 (need tests, and @1beb told us that it is not working )