Skip to content

Object count is always 0 #1470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Wouter125 opened this issue Feb 11, 2020 · 8 comments
Closed

Object count is always 0 #1470

Wouter125 opened this issue Feb 11, 2020 · 8 comments

Comments

@Wouter125
Copy link

Environment Setup

I configured my application with the following package.json;

"dependencies": {
    "@parse/s3-files-adapter": "^1.4.0",
    "parse-server": "^3.10.0",
    "parse-dashboard": "^2.0.5"
}

The parse server is hooked up to a postgresQL database, and everything is working fine. The only issue is, that the number of objects are not counted anymore. For every class it remains 0. If I delete something it turns into -1.

I inspected the network tab and noticed that my class is being fetched twice when I click on browse on the left hand side.

If I click on a specific class my network tab executes the same call twice again. The first time it's response is like this;

{"results":[],"count":0}

Second time around it's;

{"results":[{"objectId":"I92PRuHC85","createdAt":"2020-02-11T11:35:45.855Z","updatedAt":"2020-02-11T11:35:45.855Z","name":"Test"}]}

Still the count that is being used throughout the UI remains 0. It was working before, I just did a few npm updates, so perhaps it has been broken in one of the last updates?

Oh, by the way the object count does work if I explicitly filter the list...

@davimacedo
Copy link
Member

I couldn't reproduce the issue. Could you share all dependencies that you have in your package.json, yoru parse server config and your parse dashboard config?

@Wouter125
Copy link
Author

Sure!

Full package.json;

{
  "name": "prod-api",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node index.js"
  },
  "author": "Wouter",
  "license": "ISC",
  "dependencies": {
    "@parse/s3-files-adapter": "^1.4.0",
    "parse-server": "^3.10.0",
    "parse-dashboard": "^2.0.5"
  }
}

Parse server config and Parse dashboard config. Running from my DO droplet;

const express = require('express');
const { default: ParseServer, ParseGraphQLServer } = require('parse-server');
const ParseDashboard = require('parse-dashboard');
const S3Adapter = require('@parse/s3-files-adapter');
const AWS = require("aws-sdk");

// Create express app
const app = express();

// Configure DO spaces adapter
const spacesEndpoint = new AWS.Endpoint('fra1.digitaloceanspaces.com');

const S3Options = {
    bucket: '',
    baseUrl: 'https://fra1.digitaloceanspaces.com',
    region: 'fra1',
    directAccess: true,
    globalCacheControl: "public, max-age=31536000",
    bucketPrefix: '',
    s3overrides: {
        accessKeyId: '',
        secretAccessKey: '',
        endpoint: spacesEndpoint
    }
};

const filesAdapter = new S3Adapter(S3Options);

// Create Parse REST server instance
const parseServer = new ParseServer({
    databaseURI: 'postgres://{user}:{pass}@localhost:5432/database',
    appId: '',
    masterKey: '',
    readOnlyMasterKey: '',
    serverURL: 'http://localhost:1337/parse',
    allowClientClassCreation: false,
    filesAdapter: filesAdapter
});

// Create Parse GraphQL server instance
const parseGraphQLServer = new ParseGraphQLServer(
    parseServer,
    {
        graphQLPath: '/graphql',
        playgroundPath: '/playground'
    }
);

// Create Parse dashboard instance
var parseDashboard = new ParseDashboard({
    "apps": [
        {
            "serverURL": "",
            "appId": "",
            "masterKey": "",
            "readOnlyMasterKey": "",
            "graphQLServerURL": "",
            "appName": ""
        }
    ],
    "users": [
        {
            "user": "Wouter",
            "pass": ""
        },
        {
            "user": "",
            "pass": ""
        },
        { 
            "user": "",
            "pass": "",
            "readOnly": true
        }
    ],
    "useEncryptedPasswords": true
});

// Mount the REST API
app.use('/parse', parseServer.app);
    
// Mount the Dashboard
app.use('/dashboard', parseDashboard);
    
// Mount the GraphQL API
parseGraphQLServer.applyGraphQL(app);
        
// Start the server
const port = 1337;
const httpServer = require('http').createServer(app);

httpServer.listen(port, () => {
});

I've stripped out some values and passwords of course. But I think this will do the trick.

@davimacedo
Copy link
Member

Do you see any error message either in your Parse Server or Web browser console?

@Wouter125
Copy link
Author

Wouter125 commented Feb 12, 2020

I was checking that before, but unfortunately not. Only the warning that I didn't set my push notification locale. That's why I opened this issue. 😬

Is there any way I can increase the logging on the server? A verbose flag or anything? Also is it possible there is cache active on the graphQL layer or inside parse server?

I already removed postgres once and did a clean install. Also deleted the node modules and reinstalled them. Neither of them brought back the count.

@dplewis
Copy link
Member

dplewis commented Feb 13, 2020

Count operations are expensive operations. In the dashboard we use estimated count.

https://github.com/parse-community/parse-server/pull/5330/files

We should add this information in the read me as I've seen users ask about this before.

If you are using PG you can force the estimate count to update by using ANALYZE on a specific class.

@Wouter125
Copy link
Author

Wouter125 commented Feb 14, 2020

Alright, I just added some more rows to see what happens.

image

Still displaying zero. It counts on creation, and on deletion, on filtering. But it remains 0 when just rendering the list.

@dplewis
Copy link
Member

dplewis commented Feb 14, 2020

There are certain triggers that will update estimated count. If you are using Postgres check out the thread I posted before or google Autovacuum or ANALYZE command for PG.

@Wouter125
Copy link
Author

Wouter125 commented Feb 15, 2020

Gotcha. So I just ran vacuumdb -d [dbname] -v -f -F on my database, and now all counts are working correctly. Thank you for your help and explaining how this works! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants